diff options
author | The Bundler Bot <bot@bundler.io> | 2017-07-18 16:47:30 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-07-18 16:47:30 +0000 |
commit | 59a99983de7447b043a64b60868a90799841eef0 (patch) | |
tree | 38a859cec8566bdc56ef0c7f1c2c191d386260b7 | |
parent | 466568eb90cf546d108ee3dde5187ce9a470364e (diff) | |
parent | 84fafeed5482a8bdcbdf253590699b63abd9b263 (diff) | |
download | bundler-59a99983de7447b043a64b60868a90799841eef0.tar.gz |
Auto merge of #5871 - greysteil:extensions-array, r=segiddins
Return an empty array if no extensions are found
### What was the end-user problem that led to this PR?
Attempting to compare endpoint specifications that didn't have any extensions was causing a `NoMethodError: undefined method `empty?' for nil:NilClass` error.
### What was your diagnosis of the problem?
The `extensions` method on `EndpointSpecification` was incorrectly returning `nil` when there were no extensions.
### What is your fix for the problem, implemented in this PR?
~~Return an empty array in that case, instead~~ Fall back to the base class implementation in that case, instead.
### Why did you choose this fix out of the possible options?
~~Alternative would be to call `super`. I presumed there was a reason that wasn't being done already, but it would also work.~~ Alternative would be to explicitly return an empty array, but all other methods call `super`, which feels more robust.
-rw-r--r-- | lib/bundler/endpoint_specification.rb | 4 | ||||
-rw-r--r-- | spec/bundler/endpoint_specification_spec.rb | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb index 04e42c2410..b82f9529ff 100644 --- a/lib/bundler/endpoint_specification.rb +++ b/lib/bundler/endpoint_specification.rb @@ -72,6 +72,8 @@ module Bundler @remote_specification.post_install_message elsif _local_specification _local_specification.post_install_message + else + super end end @@ -81,6 +83,8 @@ module Bundler @remote_specification.extensions elsif _local_specification _local_specification.extensions + else + super end end diff --git a/spec/bundler/endpoint_specification_spec.rb b/spec/bundler/endpoint_specification_spec.rb index c89fae32f1..a9371f6617 100644 --- a/spec/bundler/endpoint_specification_spec.rb +++ b/spec/bundler/endpoint_specification_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Bundler::EndpointSpecification do let(:dependencies) { [] } let(:metadata) { nil } - subject { described_class.new(name, version, platform, dependencies, metadata) } + subject(:spec) { described_class.new(name, version, platform, dependencies, metadata) } describe "#build_dependency" do let(:name) { "foo" } @@ -62,4 +62,10 @@ RSpec.describe Bundler::EndpointSpecification do end end end + + it "supports equality comparison" do + other_spec = described_class.new("bar", version, platform, dependencies, metadata) + expect(spec).to eql(spec) + expect(spec).to_not eql(other_spec) + end end |