diff options
author | Homu <homu@barosl.com> | 2016-03-22 22:31:45 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-03-22 22:31:45 +0900 |
commit | 8edd87c82cde769bd5114a947bba656bdf90a26d (patch) | |
tree | 9e28de04995881fb72e6aa402f02d3809e34055a | |
parent | 919a9404c3103b4ecc320a01b79826aaf642817b (diff) | |
parent | f6bccae3e93369872c3c560caa9bb0d138811630 (diff) | |
download | bundler-8edd87c82cde769bd5114a947bba656bdf90a26d.tar.gz |
Auto merge of #4369 - bundler:RochesterinNYC-alias-size-to-length-spec-set, r=segiddins
Add alias `Bundler::SpecSet#size` for `Bundler::SpecSet#length`
- Closes #4368
-rw-r--r-- | lib/bundler/spec_set.rb | 2 | ||||
-rw-r--r-- | spec/bundler/spec_set_spec.rb | 43 |
2 files changed, 44 insertions, 1 deletions
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 5ec546e8e3..deb89a30fe 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -7,7 +7,7 @@ module Bundler extend Forwardable include TSort, Enumerable - def_delegators :@specs, :<<, :length, :add, :remove + def_delegators :@specs, :<<, :length, :add, :remove, :size def_delegators :sorted, :each def initialize(specs) diff --git a/spec/bundler/spec_set_spec.rb b/spec/bundler/spec_set_spec.rb new file mode 100644 index 0000000000..29d81cb30c --- /dev/null +++ b/spec/bundler/spec_set_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true +require "spec_helper" + +describe Bundler::SpecSet do + let(:specs) do + [ + build_spec("a", "1.0"), + build_spec("b", "1.0"), + build_spec("c", "1.1") do |s| + s.dep "a", "< 2.0" + s.dep "e", "> 0" + end, + build_spec("d", "2.0") do |s| + s.dep "a", "1.0" + s.dep "c", "~> 1.0" + end, + build_spec("e", "1.0.0.pre.1"), + ].flatten + end + subject { described_class.new(specs) } + + context "enumerable methods" do + it "has a length" do + expect(subject.length).to eq(5) + end + + it "has a size" do + expect(subject.size).to eq(5) + end + end + + describe "#to_a" do + it "returns the specs in order" do + expect(subject.to_a.map(&:full_name)).to eq %w( + a-1.0 + b-1.0 + e-1.0.0.pre.1 + c-1.1 + d-2.0 + ) + end + end +end |