File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,16 @@ def inject_dependencies
3636 end
3737
3838 def validate_options!
39+ raise InvalidOption , "You cannot specify `--git` and `--github` at the same time." if options [ "git" ] && options [ "github" ]
40+
41+ unless options [ "git" ] || options [ "github" ]
42+ raise InvalidOption , "You cannot specify `--branch` unless `--git` or `--github` is specified." if options [ "branch" ]
43+
44+ raise InvalidOption , "You cannot specify `--ref` unless `--git` or `--github` is specified." if options [ "ref" ]
45+ end
46+
47+ raise InvalidOption , "You cannot specify `--branch` and `--ref` at the same time." if options [ "branch" ] && options [ "ref" ]
48+
3949 raise InvalidOption , "You cannot specify `--strict` and `--optimistic` at the same time." if options [ :strict ] && options [ :optimistic ]
4050
4151 # raise error when no gems are specified
Original file line number Diff line number Diff line change 236236 end
237237 end
238238
239+ describe "with mismatched pair in --git/--github, --branch/--ref" do
240+ describe "with --git and --github" do
241+ it "throws error" do
242+ bundle "add 'foo' --git x --github y" , :raise_on_error => false
243+
244+ expect ( err ) . to include ( "You cannot specify `--git` and `--github` at the same time." )
245+ end
246+ end
247+
248+ describe "with --branch and --ref with --git" do
249+ it "throws error" do
250+ bundle "add 'foo' --branch x --ref y --git file://git" , :raise_on_error => false
251+
252+ expect ( err ) . to include ( "You cannot specify `--branch` and `--ref` at the same time." )
253+ end
254+ end
255+
256+ describe "with --branch but without --git or --github" do
257+ it "throws error" do
258+ bundle "add 'foo' --branch x" , :raise_on_error => false
259+
260+ expect ( err ) . to include ( "You cannot specify `--branch` unless `--git` or `--github` is specified." )
261+ end
262+ end
263+
264+ describe "with --ref but without --git or --github" do
265+ it "throws error" do
266+ bundle "add 'foo' --ref y" , :raise_on_error => false
267+
268+ expect ( err ) . to include ( "You cannot specify `--ref` unless `--git` or `--github` is specified." )
269+ end
270+ end
271+ end
272+
239273 describe "with --skip-install" do
240274 it "adds gem to Gemfile but is not installed" do
241275 bundle "add foo --skip-install --version=2.0"
You can’t perform that action at this time.
0 commit comments