diff options
author | Andre Arko <andre@arko.net> | 2015-06-19 15:40:55 -0500 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-06-19 16:13:18 -0500 |
commit | 3f4f6286c56765e8c4968631643106cfd534b789 (patch) | |
tree | 349b7a3738cfafaa42405a123e4f2eb500e8b144 | |
parent | ec8093c8deea290b4062f7fd116f5214f9d3f28a (diff) | |
download | bundler-3f4f6286c56765e8c4968631643106cfd534b789.tar.gz |
Allow comparing Bundler StubSpecs with RG specs
/ht @tony-spataro-rs
fixes #3762
-rw-r--r-- | lib/bundler/remote_specification.rb | 13 | ||||
-rw-r--r-- | spec/bundler/remote_specification_spec.rb | 14 |
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 |