diff options
author | Julian Nadeau <julian@jnadeau.ca> | 2017-05-01 23:40:31 -0400 |
---|---|---|
committer | Julian Nadeau <julian@jnadeau.ca> | 2017-05-05 10:04:10 -0400 |
commit | 51623aae48bdf0365d577c6d9d4e1930ba328180 (patch) | |
tree | 8a924c99717017036c89b0b9a4c46d733a0585a9 | |
parent | d085451947d41a0a3cdde3fd28723e11b842db7c (diff) | |
download | bundler-51623aae48bdf0365d577c6d9d4e1930ba328180.tar.gz |
Return Bundler::StubSpec if stub is a Bundler::StubSpec
-rw-r--r-- | lib/bundler/stub_specification.rb | 1 | ||||
-rw-r--r-- | spec/bundler/stub_specification_spec.rb | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index d5f6a883f9..aeacf245a3 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -4,6 +4,7 @@ require "bundler/remote_specification" module Bundler class StubSpecification < RemoteSpecification def self.from_stub(stub) + return stub if stub.is_a?(Bundler::StubSpecification) spec = new(stub.name, stub.version, stub.platform, nil) spec.stub = stub spec diff --git a/spec/bundler/stub_specification_spec.rb b/spec/bundler/stub_specification_spec.rb new file mode 100644 index 0000000000..ecfe2412ee --- /dev/null +++ b/spec/bundler/stub_specification_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +require "spec_helper" + +if Bundler.rubygems.provides?(">= 2.1") + RSpec.describe Bundler::StubSpecification do + let(:with_gem_stub_spec) do + stub = Gem::Specification.stubs.first + described_class.from_stub(stub) + end + + let(:with_bundler_stub_spec) do + described_class.from_stub(with_gem_stub_spec) + end + + describe "#from_stub" do + it "returns the same stub if already a Bundler::StubSpecification" do + stub = described_class.from_stub(with_bundler_stub_spec) + expect(stub).to be(with_bundler_stub_spec) + end + end + end +end |