diff options
Diffstat (limited to 'spec/commands')
-rw-r--r-- | spec/commands/add_spec.rb | 9 | ||||
-rw-r--r-- | spec/commands/cache_spec.rb (renamed from spec/commands/package_spec.rb) | 34 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 6 | ||||
-rw-r--r-- | spec/commands/info_spec.rb | 17 | ||||
-rw-r--r-- | spec/commands/list_spec.rb | 23 | ||||
-rw-r--r-- | spec/commands/newgem_spec.rb | 4 |
6 files changed, 71 insertions, 22 deletions
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index fdfca5d8f2..35fd43d3d2 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -239,4 +239,13 @@ RSpec.describe "bundle add" do expect(err).not_to include("You may also need to change the version requirement specified in the Gemfile if it's too restrictive") end end + + describe "when a gem is added and cache exists" do + it "caches all new dependencies added for the specified gem" do + bundle! :cache + + bundle "add 'rack' --version=1.0.0" + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + end + end end diff --git a/spec/commands/package_spec.rb b/spec/commands/cache_spec.rb index da22c002eb..07ec186c2f 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/cache_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "bundle package" do +RSpec.describe "bundle cache" do context "with --gemfile" do it "finds the gemfile" do gemfile bundled_app("NotGemfile"), <<-G @@ -8,7 +8,7 @@ RSpec.describe "bundle package" do gem 'rack' G - bundle "package --gemfile=NotGemfile" + bundle "cache --gemfile=NotGemfile" ENV["BUNDLE_GEMFILE"] = "NotGemfile" expect(the_bundle).to include_gems "rack 1.0.0" @@ -25,7 +25,7 @@ RSpec.describe "bundle package" do D bundle "config set cache_all true" - bundle :package + bundle :cache expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist @@ -56,7 +56,7 @@ RSpec.describe "bundle package" do D bundle "config set cache_all true" - bundle! :package + bundle! :cache expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist @@ -88,7 +88,7 @@ RSpec.describe "bundle package" do D bundle "config set cache_all true" - bundle! :package + bundle! :cache expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist @@ -133,7 +133,7 @@ RSpec.describe "bundle package" do D bundle "config set cache_all true" - bundle! :package + bundle! :cache expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist @@ -152,7 +152,7 @@ RSpec.describe "bundle package" do gem 'rack' D - bundle! :package, forgotten_command_line_options(:path => bundled_app("test")) + bundle! :cache, forgotten_command_line_options(:path => bundled_app("test")) expect(the_bundle).to include_gems "rack 1.0.0" expect(bundled_app("test/vendor/cache/")).to exist @@ -166,7 +166,7 @@ RSpec.describe "bundle package" do gem 'rack' D - bundle! "package --no-install" + bundle! "cache --no-install" expect(the_bundle).not_to include_gems "rack 1.0.0" expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist @@ -178,7 +178,7 @@ RSpec.describe "bundle package" do gem 'rack' D - bundle! "package --no-install" + bundle! "cache --no-install" bundle! "install" expect(the_bundle).to include_gems "rack 1.0.0" @@ -190,7 +190,7 @@ RSpec.describe "bundle package" do gem "rack", "1.0.0" D - bundle! "package --no-install" + bundle! "cache --no-install" bundle! "update --all" expect(the_bundle).to include_gems "rack 1.0.0" @@ -204,7 +204,7 @@ RSpec.describe "bundle package" do gem 'rack', :platforms => :ruby_19 D - bundle "package --all-platforms" + bundle "cache --all-platforms" expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist end @@ -226,7 +226,7 @@ RSpec.describe "bundle package" do end G - bundle! :package, "all-platforms" => true + bundle! :cache, "all-platforms" => true expect(bundled_app("vendor/cache/weakling-0.0.3.gem")).to exist expect(bundled_app("vendor/cache/uninstallable-2.0.gem")).to exist expect(the_bundle).to include_gem "rack 1.0" @@ -247,7 +247,7 @@ RSpec.describe "bundle package" do bundle "install" end - subject { bundle :package, forgotten_command_line_options(:frozen => true) } + subject { bundle :cache, forgotten_command_line_options(:frozen => true) } it "tries to install with frozen" do bundle! "config set deployment true" @@ -276,7 +276,7 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G - bundle :pack + bundle :cache simulate_new_machine FileUtils.rm_rf gem_repo2 @@ -291,7 +291,7 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G - bundle! :pack + bundle! :cache simulate_new_machine FileUtils.rm_rf gem_repo2 @@ -304,7 +304,7 @@ RSpec.describe "bundle install with gem sources" do source "#{file_uri_for(gem_repo1)}" gem "rack" G - bundle :pack + bundle :cache build_gem "rack", "1.0.0", :path => bundled_app("vendor/cache") do |s| s.write "lib/rack.rb", "raise 'omg'" @@ -321,7 +321,7 @@ RSpec.describe "bundle install with gem sources" do source "#{file_uri_for(gem_repo1)}" gem "platform_specific" G - bundle :pack + bundle :cache end simulate_new_machine diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index cf76d3fb93..7ae504d360 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -89,7 +89,7 @@ RSpec.describe "bundle exec" do else require 'tempfile' io = Tempfile.new("io-test-fd") - args = %W[#{Gem.ruby} -I#{lib} #{bindir.join("bundle")} exec --keep-file-descriptors #{Gem.ruby} #{command.path} \#{io.to_i}] + args = %W[#{Gem.ruby} -I#{lib_dir} #{bindir.join("bundle")} exec --keep-file-descriptors #{Gem.ruby} #{command.path} \#{io.to_i}] args << { io.to_i => io } exec(*args) end @@ -279,7 +279,7 @@ RSpec.describe "bundle exec" do G rubyopt = ENV["RUBYOPT"] - rubyopt = "-r#{lib}/bundler/setup #{rubyopt}" + rubyopt = "-r#{lib_dir}/bundler/setup #{rubyopt}" bundle "exec 'echo $RUBYOPT'" expect(out).to have_rubyopts(rubyopt) @@ -294,7 +294,7 @@ RSpec.describe "bundle exec" do G rubylib = ENV["RUBYLIB"] - rubylib = rubylib.to_s.split(File::PATH_SEPARATOR).unshift lib.to_s + rubylib = rubylib.to_s.split(File::PATH_SEPARATOR).unshift lib_dir.to_s rubylib = rubylib.uniq.join(File::PATH_SEPARATOR) bundle "exec 'echo $RUBYLIB'" diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb index 4572823498..881f66d440 100644 --- a/spec/commands/info_spec.rb +++ b/spec/commands/info_spec.rb @@ -6,6 +6,7 @@ RSpec.describe "bundle info" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rails" + gem "has_metadata" G end @@ -48,6 +49,22 @@ RSpec.describe "bundle info" do end end + context "given a gem with metadata" do + it "prints the gem metadata" do + bundle "info has_metadata" + expect(out).to include "* has_metadata (1.0) +\tSummary: This is just a fake gem for testing +\tHomepage: http://example.com +\tDocumentation: https://www.example.info/gems/bestgemever/0.0.1 +\tSource Code: https://example.com/user/bestgemever +\tWiki: https://example.com/user/bestgemever/wiki +\tChangelog: https://example.com/user/bestgemever/CHANGELOG.md +\tBug Tracker: https://example.com/user/bestgemever/issues +\tMailing List: https://groups.example.com/bestgemever +\tPath: #{default_bundle_path("gems", "has_metadata-1.0")}" + end + end + context "when gem does not have homepage" do before do build_repo2 do diff --git a/spec/commands/list_spec.rb b/spec/commands/list_spec.rb index 71d2136d38..60efd38cb7 100644 --- a/spec/commands/list_spec.rb +++ b/spec/commands/list_spec.rb @@ -24,6 +24,7 @@ RSpec.describe "bundle list" do gem "rack" gem "rspec", :group => [:test] + gem "rails", :group => [:production] G end @@ -32,6 +33,7 @@ RSpec.describe "bundle list" do bundle! "list --without-group test" expect(out).to include(" * rack (1.0.0)") + expect(out).to include(" * rails (2.3.2)") expect(out).not_to include(" * rspec (1.2.7)") end end @@ -43,6 +45,16 @@ RSpec.describe "bundle list" do expect(err).to eq "`random` group could not be found." end end + + context "when multiple groups" do + it "prints the gems not in the specified groups" do + bundle! "list --without-group test production" + + expect(out).to include(" * rack (1.0.0)") + expect(out).not_to include(" * rails (2.3.2)") + expect(out).not_to include(" * rspec (1.2.7)") + end + end end describe "with only-group option" do @@ -52,6 +64,7 @@ RSpec.describe "bundle list" do gem "rack" gem "rspec", :group => [:test] + gem "rails", :group => [:production] G end @@ -71,6 +84,16 @@ RSpec.describe "bundle list" do expect(err).to eq "`random` group could not be found." end end + + context "when multiple groups" do + it "prints the gems in the specified groups" do + bundle! "list --only-group default production" + + expect(out).to include(" * rack (1.0.0)") + expect(out).to include(" * rails (2.3.2)") + expect(out).not_to include(" * rspec (1.2.7)") + end + end end context "with name-only option" do diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index cda74d3d7f..2c8ab4b5ef 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -26,7 +26,7 @@ RSpec.describe "bundle gem" do user = bundleuser EOF @git_config_location = ENV["GIT_CONFIG"] - path = "#{File.expand_path(tmp, File.dirname(__FILE__))}/test_git_config.txt" + path = "#{tmp}/test_git_config.txt" File.open(path, "w") {|f| f.write(git_config_content) } ENV["GIT_CONFIG"] = path end @@ -230,7 +230,7 @@ RSpec.describe "bundle gem" do context "when git is not available" do # This spec cannot have `git` available in the test env before do - load_paths = [lib, spec] + load_paths = [lib_dir, spec_dir] load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}" sys_exec "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", "PATH" => "" |