summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2015-06-19 15:40:55 -0500
committerAndre Arko <andre@arko.net>2015-06-19 16:13:18 -0500
commit3f4f6286c56765e8c4968631643106cfd534b789 (patch)
tree349b7a3738cfafaa42405a123e4f2eb500e8b144
parentec8093c8deea290b4062f7fd116f5214f9d3f28a (diff)
downloadbundler-3f4f6286c56765e8c4968631643106cfd534b789.tar.gz
Allow comparing Bundler StubSpecs with RG specs
/ht @tony-spataro-rs fixes #3762
-rw-r--r--lib/bundler/remote_specification.rb13
-rw-r--r--spec/bundler/remote_specification_spec.rb14
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb
index c80eaa40fc..d8bd5c331f 100644
--- a/lib/bundler/remote_specification.rb
+++ b/lib/bundler/remote_specification.rb
@@ -8,6 +8,7 @@ module Bundler
# full specification will only be fetched when necessary.
class RemoteSpecification
include MatchPlatform
+ include Comparable
attr_reader :name, :version, :platform
attr_accessor :source, :remote
@@ -33,17 +34,25 @@ module Bundler
end
end
+ def <=>(other)
+ if other.respond_to?(:full_name)
+ full_name <=> other.full_name
+ else
+ super
+ end
+ end
+
# Because Rubyforge cannot be trusted to provide valid specifications
# once the remote gem is downloaded, the backend specification will
# be swapped out.
def __swap__(spec)
- @specification = spec
+ @_remote_specification = spec
end
private
def _remote_specification
- @specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform])
+ @_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform])
end
def method_missing(method, *args, &blk)
diff --git a/spec/bundler/remote_specification_spec.rb b/spec/bundler/remote_specification_spec.rb
new file mode 100644
index 0000000000..250c48c124
--- /dev/null
+++ b/spec/bundler/remote_specification_spec.rb
@@ -0,0 +1,14 @@
+require "spec_helper"
+
+describe Bundler::RemoteSpecification do
+ subject(:spec) { Bundler::RemoteSpecification.new("foo", "1.2", "ruby", fetcher) }
+ let(:fetcher) { double("SpecFetcher", :fetch_spec => rubygems_spec)}
+ let(:rubygems_spec) { Gem::Specification.new("foo", "1.2") }
+
+ describe "<=>" do
+ let(:other_spec) { Gem::Specification.new("bar", "1.0") }
+ it "sorts with Gem::Specification" do
+ expect(spec <=> other_spec).to eq(1)
+ end
+ end
+end \ No newline at end of file