diff options
author | Dennis Suratna <dennis.suratna@gmail.com> | 2017-03-31 11:44:54 -0700 |
---|---|---|
committer | Dennis Suratna <dennis.suratna@gmail.com> | 2017-04-10 15:46:27 +0700 |
commit | 5c42e22a1aacc3d0060c9d354be088586b1d46e6 (patch) | |
tree | 9c6d16e189f58c7d82c43f045aadb3e9c15db175 /spec/commands | |
parent | 668e37e0840baf05d174e73eb695a7dc959227d1 (diff) | |
download | bundler-5c42e22a1aacc3d0060c9d354be088586b1d46e6.tar.gz |
Add negative testing
Diffstat (limited to 'spec/commands')
-rw-r--r-- | spec/commands/add_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index 451cc2ed2b..12a8155ac1 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -79,4 +79,28 @@ RSpec.describe "bundle add" do expect(the_bundle).to include_gems "foo 2.0" end end + + it "using combination of short form options works like long form" do + bundle "add 'foo' -s='file://#{gem_repo2}' -g='development' -v='~>1.0'" + expect(bundled_app("Gemfile").read).to match(%r{gem "foo", "~> 1.0", :group => \[:development\], :source => 'file:\/\/#{gem_repo2}'}) + expect(the_bundle).to include_gems "foo 1.1" + end + + it "shows error message when version is not formatted correctly" do + bundle "add 'foo' -v='~>1 . 0'" + expect(out).to match('Illformed requirement ["~>1 . 0"]') + end + + it "shows error message when gem cannot be found" do + bundle "add 'werk_it'" + expect(out).to match("Could not find gem 'werk_it' in any of the gem sources listed in your Gemfile.") + end + + it "shows error message when source cannot be reached" do + bundle "add 'baz' --source='http://badhostasdf'" + expect(out).to include("Could not reach host badhostasdf. Check your network connection and try again.") + + bundle "add 'baz' --source='file://does/not/exist'" + expect(out).to include("Could not fetch specs from file://does/not/exist/") + end end |