Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Gem::Platforms aren't comparable, so convert to strings

  • Loading branch information...
commit 1e3a587033adfa5496265b4a995f5b77643ebfa3 1 parent b81b730
@brynary brynary authored Carl Lerche committed
View
2  lib/bundler/resolver.rb
@@ -235,7 +235,7 @@ def search(dependency)
found.reject! { |spec| spec.version.prerelease? }
end
- found.sort_by {|s| [s.version, s.platform == 'ruby' ? "\0" : s.platform] }
+ found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
end
end
end
View
14 spec/resolver/engine_spec.rb
@@ -16,6 +16,20 @@
)
end
+ it "prefers JRuby gems" do
+ index = build_index do
+ add_spec "bar", "2.0.0", [nil, "jruby", nil]
+ add_spec "bar", "2.0.0", [nil, "ruby", nil]
+ end
+
+ deps = [
+ build_dep("bar", ">= 1.2.3"),
+ ]
+
+ solution = Bundler::Resolver.resolve(deps, [index])
+ solution.first.platform.should == Gem::Platform.new([nil, "jruby", nil])
+ end
+
it "supports a crazy case" do
index = build_index do
add_spec "activemerchant", "1.4.1" do
View
3  spec/support/builders.rb
@@ -115,10 +115,11 @@ def build_index(&block)
index
end
- def build_spec(name, version, &block)
+ def build_spec(name, version, platform = nil, &block)
spec = Gem::Specification.new
spec.instance_variable_set(:@name, name)
spec.instance_variable_set(:@version, Gem::Version.new(version))
+ spec.platform = Gem::Platform.new(platform) if platform
DepBuilder.run(spec, &block) if block_given?
spec
end
Please sign in to comment.
Something went wrong with that request. Please try again.