diff options
author | t ddddddd <miscmisc@cmme.org> | 2013-12-01 19:25:07 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-12-20 10:32:01 -0800 |
commit | f4c9f0e04b3394738184fdaeb829896ef1ad8190 (patch) | |
tree | 6fbc60fd51c322d41610e85d930888f08c1c4cb8 /spec/commands/show_spec.rb | |
parent | be6cc8002a434963e5e71a9855ccaea6ba7513b3 (diff) | |
download | bundler-f4c9f0e04b3394738184fdaeb829896ef1ad8190.tar.gz |
Refactor "bundle show" spec into high-level context blocks
Diffstat (limited to 'spec/commands/show_spec.rb')
-rw-r--r-- | spec/commands/show_spec.rb | 148 |
1 files changed, 75 insertions, 73 deletions
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index bdd3a1f6a2..5ff0cc0242 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -1,102 +1,104 @@ require "spec_helper" describe "bundle show" do - before :each do - install_gemfile <<-G - source "file://#{gem_repo1}" - gem "rails" - G - end - - it "creates a Gemfile.lock if one did not exist" do - FileUtils.rm("Gemfile.lock") + context "with a standard Gemfile" do + before :each do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rails" + G + end - bundle "show" + it "creates a Gemfile.lock if one did not exist" do + FileUtils.rm("Gemfile.lock") - expect(bundled_app("Gemfile.lock")).to exist - end + bundle "show" - it "creates a Gemfile.lock when invoked with a gem name" do - FileUtils.rm("Gemfile.lock") + expect(bundled_app("Gemfile.lock")).to exist + end - bundle "show rails" + it "creates a Gemfile.lock when invoked with a gem name" do + FileUtils.rm("Gemfile.lock") - expect(bundled_app("Gemfile.lock")).to exist - end + bundle "show rails" - it "prints path if gem exists in bundle" do - bundle "show rails" - expect(out).to eq(default_bundle_path('gems', 'rails-2.3.2').to_s) - end + expect(bundled_app("Gemfile.lock")).to exist + end - it "warns if path no longer exists on disk" do - FileUtils.rm_rf("#{system_gem_path}/gems/rails-2.3.2") + it "prints path if gem exists in bundle" do + bundle "show rails" + expect(out).to eq(default_bundle_path('gems', 'rails-2.3.2').to_s) + end - bundle "show rails" + it "warns if path no longer exists on disk" do + FileUtils.rm_rf("#{system_gem_path}/gems/rails-2.3.2") - expect(out).to match(/has been deleted/i) - expect(out).to include(default_bundle_path('gems', 'rails-2.3.2').to_s) - end + bundle "show rails" - it "prints the path to the running bundler" do - bundle "show bundler" - expect(out).to eq(File.expand_path('../../../', __FILE__)) - end + expect(out).to match(/has been deleted/i) + expect(out).to include(default_bundle_path('gems', 'rails-2.3.2').to_s) + end - it "complains if gem not in bundle" do - bundle "show missing" - expect(out).to match(/could not find gem 'missing'/i) - end + it "prints the path to the running bundler" do + bundle "show bundler" + expect(out).to eq(File.expand_path('../../../', __FILE__)) + end - it "prints path of all gems in bundle sorted by name" do - bundle "show --paths" + it "complains if gem not in bundle" do + bundle "show missing" + expect(out).to match(/could not find gem 'missing'/i) + end - expect(out).to include(default_bundle_path('gems', 'rake-10.0.2').to_s) - expect(out).to include(default_bundle_path('gems', 'rails-2.3.2').to_s) + it "prints path of all gems in bundle sorted by name" do + bundle "show --paths" - # Gem names are the last component of their path. - gem_list = out.split.map { |p| p.split('/').last } - expect(gem_list).to eq(gem_list.sort) - end -end + expect(out).to include(default_bundle_path('gems', 'rake-10.0.2').to_s) + expect(out).to include(default_bundle_path('gems', 'rails-2.3.2').to_s) -describe "bundle show with a git repo" do - before :each do - @git = build_git "foo", "1.0" + # Gem names are the last component of their path. + gem_list = out.split.map { |p| p.split('/').last } + expect(gem_list).to eq(gem_list.sort) + end end - it "prints out git info" do - install_gemfile <<-G - gem "foo", :git => "#{lib_path('foo-1.0')}" - G - should_be_installed "foo 1.0" + context "with a git repo in the Gemfile" do + before :each do + @git = build_git "foo", "1.0" + end - bundle :show - expect(out).to include("foo (1.0 #{@git.ref_for('master', 6)}") - end + it "prints out git info" do + install_gemfile <<-G + gem "foo", :git => "#{lib_path('foo-1.0')}" + G + should_be_installed "foo 1.0" - it "prints out branch names other than master" do - update_git "foo", :branch => "omg" do |s| - s.write "lib/foo.rb", "FOO = '1.0.omg'" + bundle :show + expect(out).to include("foo (1.0 #{@git.ref_for('master', 6)}") end - @revision = revision_for(lib_path("foo-1.0"))[0...6] - install_gemfile <<-G - gem "foo", :git => "#{lib_path('foo-1.0')}", :branch => "omg" - G - should_be_installed "foo 1.0.omg" + it "prints out branch names other than master" do + update_git "foo", :branch => "omg" do |s| + s.write "lib/foo.rb", "FOO = '1.0.omg'" + end + @revision = revision_for(lib_path("foo-1.0"))[0...6] - bundle :show - expect(out).to include("foo (1.0 #{@git.ref_for('omg', 6)}") - end + install_gemfile <<-G + gem "foo", :git => "#{lib_path('foo-1.0')}", :branch => "omg" + G + should_be_installed "foo 1.0.omg" - it "doesn't print the branch when tied to a ref" do - sha = revision_for(lib_path("foo-1.0")) - install_gemfile <<-G - gem "foo", :git => "#{lib_path('foo-1.0')}", :ref => "#{sha}" - G + bundle :show + expect(out).to include("foo (1.0 #{@git.ref_for('omg', 6)}") + end + + it "doesn't print the branch when tied to a ref" do + sha = revision_for(lib_path("foo-1.0")) + install_gemfile <<-G + gem "foo", :git => "#{lib_path('foo-1.0')}", :ref => "#{sha}" + G - bundle :show - expect(out).to include("foo (1.0 #{sha[0..6]})") + bundle :show + expect(out).to include("foo (1.0 #{sha[0..6]})") + end end end |