summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-05-16 14:08:58 +0900
committerHomu <homu@barosl.com>2016-05-16 14:08:58 +0900
commitd23c26442a0e4caec73b5f85c21fc4738c7bc19f (patch)
tree993c92ff7fdf66bb627d35283528a806d3ecf06d
parent495dc7e0631cfb5cdac685250fcb41c090dfa610 (diff)
parentae1fbe5e0edfd4996846b09c6954fa6f2ac41c36 (diff)
downloadbundler-d23c26442a0e4caec73b5f85c21fc4738c7bc19f.tar.gz
Auto merge of #4558 - bundler:seg-index-platform-ruby-default, r=segiddins
[Index] Ensure nil and "ruby" platforms are treated identically Fixes #4557. @indirect @RochesterinNYC ideas on how to test this?
-rw-r--r--lib/bundler/index.rb4
-rw-r--r--spec/bundler/index_spec.rb29
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index f2defe1cff..5c49034280 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -89,7 +89,7 @@ module Bundler
alias_method :[], :search
def <<(spec)
- @specs[spec.name]["#{spec.version}-#{spec.platform}"] = spec
+ @specs[spec.name][spec.full_name] = spec
spec
end
@@ -175,7 +175,7 @@ module Bundler
end
def search_by_spec(spec)
- spec = @specs[spec.name]["#{spec.version}-#{spec.platform}"]
+ spec = @specs[spec.name][spec.full_name]
spec ? [spec] : []
end
diff --git a/spec/bundler/index_spec.rb b/spec/bundler/index_spec.rb
new file mode 100644
index 0000000000..da8e5731ca
--- /dev/null
+++ b/spec/bundler/index_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+require "spec_helper"
+
+describe Bundler::Index do
+ let(:specs) { [] }
+ subject { described_class.build {|i| i.use(specs) } }
+
+ context "specs with a nil platform" do
+ let(:spec) do
+ Gem::Specification.new do |s|
+ s.name = "json"
+ s.version = "1.8.3"
+ allow(s).to receive(:platform).and_return(nil)
+ end
+ end
+ let(:specs) { [spec] }
+
+ describe "#search_by_spec" do
+ it "finds the spec when a nil platform is specified" do
+ expect(subject.search(spec)).to eq([spec])
+ end
+
+ it "finds the spec when a ruby platform is specified" do
+ query = spec.dup.tap {|s| s.platform = "ruby" }
+ expect(subject.search(query)).to eq([spec])
+ end
+ end
+ end
+end