diff options
author | Colby Swandale <colby@taplaboratories.com> | 2017-04-08 12:44:28 +1000 |
---|---|---|
committer | Colby Swandale <colby@taplaboratories.com> | 2017-04-08 13:02:34 +1000 |
commit | 261afb919826d14b2c2b72c290635b11f3e1de7b (patch) | |
tree | 4aba7555fc6fbf6cebb56b06b18124e1872eb172 | |
parent | 344f487a4ca2ad6d41c22291a04c46dd7006bac0 (diff) | |
download | bundler-261afb919826d14b2c2b72c290635b11f3e1de7b.tar.gz |
fix using branch with git_source with spec
-rw-r--r-- | lib/bundler/dsl.rb | 3 | ||||
-rw-r--r-- | spec/bundler/dsl_spec.rb | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index b1f2dec39e..9bbabfee19 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -385,7 +385,8 @@ module Bundler def validate_keys(command, opts, valid_keys) invalid_keys = opts.keys - valid_keys - if opts["branch"] && !(opts["git"] || opts["github"]) + git_source = opts.keys & @git_sources.keys.map(&:to_s) + if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?) raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch) end diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 5537dd7a48..4f5eb6dc92 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -155,6 +155,13 @@ RSpec.describe Bundler::Dsl do dep = subject.dependencies.last expect(dep.name).to eq "foo" end + + it "allows specifiying a branch on git gems with a git_source" do + subject.git_source(:test_source) {|n| "https://github.com/#{n}" } + subject.gem("foo", :branch => "test", :test_source => "bundler/bundler") + dep = subject.dependencies.last + expect(dep.name).to eq "foo" + end end describe "#gemspec" do |