diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-01-11 13:50:21 +0100 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-01-12 16:31:06 +0100 |
commit | d4b6a4164ac7fac1de4c352a04e80dfd8b3a601a (patch) | |
tree | f595fa91f100d8c26bcc5dd3cf69b2c21287dc2c /spec/commands | |
parent | 2c26c8c2f3b2d8c68c2170ba06193b1d13847738 (diff) | |
download | bundler-d4b6a4164ac7fac1de4c352a04e80dfd8b3a601a.tar.gz |
Extract `bundled_app_gemfile` path helper
Diffstat (limited to 'spec/commands')
-rw-r--r-- | spec/commands/add_spec.rb | 36 | ||||
-rw-r--r-- | spec/commands/init_spec.rb | 6 | ||||
-rw-r--r-- | spec/commands/inject_spec.rb | 12 | ||||
-rw-r--r-- | spec/commands/remove_spec.rb | 6 |
4 files changed, 30 insertions, 30 deletions
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index 35fd43d3d2..672b1ffa52 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -30,25 +30,25 @@ RSpec.describe "bundle add" do describe "without version specified" do it "version requirement becomes ~> major.minor.patch when resolved version is < 1.0" do bundle "add 'bar'" - expect(bundled_app("Gemfile").read).to match(/gem "bar", "~> 0.12.3"/) + expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/) expect(the_bundle).to include_gems "bar 0.12.3" end it "version requirement becomes ~> major.minor when resolved version is > 1.0" do bundle "add 'baz'" - expect(bundled_app("Gemfile").read).to match(/gem "baz", "~> 1.2"/) + expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/) expect(the_bundle).to include_gems "baz 1.2.3" end it "version requirement becomes ~> major.minor.patch.pre when resolved version is < 1.0" do bundle "add 'cat'" - expect(bundled_app("Gemfile").read).to match(/gem "cat", "~> 0.12.3.pre"/) + expect(bundled_app_gemfile.read).to match(/gem "cat", "~> 0.12.3.pre"/) expect(the_bundle).to include_gems "cat 0.12.3.pre" end it "version requirement becomes ~> major.minor.pre when resolved version is > 1.0.pre" do bundle "add 'dog'" - expect(bundled_app("Gemfile").read).to match(/gem "dog", "~> 1.1.pre"/) + expect(bundled_app_gemfile.read).to match(/gem "dog", "~> 1.1.pre"/) expect(the_bundle).to include_gems "dog 1.1.3.pre" end end @@ -56,14 +56,14 @@ RSpec.describe "bundle add" do describe "with --version" do it "adds dependency of specified version and runs install" do bundle "add 'foo' --version='~> 1.0'" - expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 1.0"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 1.0"/) expect(the_bundle).to include_gems "foo 1.1" end it "adds multiple version constraints when specified" do requirements = ["< 3.0", "> 1.0"] bundle "add 'foo' --version='#{requirements.join(", ")}'" - expect(bundled_app("Gemfile").read).to match(/gem "foo", #{Gem::Requirement.new(requirements).as_list.map(&:dump).join(', ')}/) + expect(bundled_app_gemfile.read).to match(/gem "foo", #{Gem::Requirement.new(requirements).as_list.map(&:dump).join(', ')}/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -71,13 +71,13 @@ RSpec.describe "bundle add" do describe "with --group" do it "adds dependency for the specified group" do bundle "add 'foo' --group='development'" - expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :group => :development/) + expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :group => :development/) expect(the_bundle).to include_gems "foo 2.0" end it "adds dependency to more than one group" do bundle "add 'foo' --group='development, test'" - expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :groups => \[:development, :test\]/) + expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :groups => \[:development, :test\]/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -86,7 +86,7 @@ RSpec.describe "bundle add" do it "adds dependency with specified source" do bundle "add 'foo' --source='#{file_uri_for(gem_repo2)}'" - expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :source => "#{file_uri_for(gem_repo2)}"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :source => "#{file_uri_for(gem_repo2)}"/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -95,7 +95,7 @@ RSpec.describe "bundle add" do it "adds dependency with specified github source" do bundle "add foo --git=#{lib_path("foo-2.0")}" - expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -108,7 +108,7 @@ RSpec.describe "bundle add" do it "adds dependency with specified github source and branch" do bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test" - expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -117,14 +117,14 @@ RSpec.describe "bundle add" do it "adds gem to Gemfile but is not installed" do bundle "add foo --skip-install --version=2.0" - expect(bundled_app("Gemfile").read).to match(/gem "foo", "= 2.0"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", "= 2.0"/) expect(the_bundle).to_not include_gems "foo 2.0" end end it "using combination of short form options works like long form" do bundle "add 'foo' -s='#{file_uri_for(gem_repo2)}' -g='development' -v='~>1.0'" - expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => :development, :source => "#{file_uri_for(gem_repo2)}") + expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 1.0", :group => :development, :source => "#{file_uri_for(gem_repo2)}") expect(the_bundle).to include_gems "foo 1.1" end @@ -153,7 +153,7 @@ RSpec.describe "bundle add" do describe "with --optimistic" do it "adds optimistic version" do bundle! "add 'foo' --optimistic" - expect(bundled_app("Gemfile").read).to include %(gem "foo", ">= 2.0") + expect(bundled_app_gemfile.read).to include %(gem "foo", ">= 2.0") expect(the_bundle).to include_gems "foo 2.0" end end @@ -161,7 +161,7 @@ RSpec.describe "bundle add" do describe "with --strict option" do it "adds strict version" do bundle! "add 'foo' --strict" - expect(bundled_app("Gemfile").read).to include %(gem "foo", "= 2.0") + expect(bundled_app_gemfile.read).to include %(gem "foo", "= 2.0") expect(the_bundle).to include_gems "foo 2.0" end end @@ -169,7 +169,7 @@ RSpec.describe "bundle add" do describe "with no option" do it "adds pessimistic version" do bundle! "add 'foo'" - expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 2.0") + expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 2.0") expect(the_bundle).to include_gems "foo 2.0" end end @@ -186,8 +186,8 @@ RSpec.describe "bundle add" do it "adds multiple gems to gemfile" do bundle! "add bar baz" - expect(bundled_app("Gemfile").read).to match(/gem "bar", "~> 0.12.3"/) - expect(bundled_app("Gemfile").read).to match(/gem "baz", "~> 1.2"/) + expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/) + expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/) end it "throws error if any of the specified gems are present in the gemfile with different version" do diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb index 7960ce85bd..1fb83827c2 100644 --- a/spec/commands/init_spec.rb +++ b/spec/commands/init_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "bundle init" do it "generates a Gemfile" do bundle! :init expect(out).to include("Writing new Gemfile") - expect(bundled_app("Gemfile")).to be_file + expect(bundled_app_gemfile).to be_file end context "when a Gemfile already exists" do @@ -15,7 +15,7 @@ RSpec.describe "bundle init" do end it "does not change existing Gemfiles" do - expect { bundle :init }.not_to change { File.read(bundled_app("Gemfile")) } + expect { bundle :init }.not_to change { File.read(bundled_app_gemfile) } end it "notifies the user that an existing Gemfile already exists" do @@ -75,7 +75,7 @@ RSpec.describe "bundle init" do bundle :init, :gemspec => spec_file - gemfile = bundled_app("Gemfile").read + gemfile = bundled_app_gemfile.read expect(gemfile).to match(%r{source 'https://rubygems.org'}) expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1) expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1) diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb index c5c63935af..78355edab3 100644 --- a/spec/commands/inject_spec.rb +++ b/spec/commands/inject_spec.rb @@ -22,9 +22,9 @@ RSpec.describe "bundle inject", :bundler => "< 3" do end it "adds the injected gems to the Gemfile" do - expect(bundled_app("Gemfile").read).not_to match(/rack-obama/) + expect(bundled_app_gemfile.read).not_to match(/rack-obama/) bundle "inject 'rack-obama' '> 0'" - expect(bundled_app("Gemfile").read).to match(/rack-obama/) + expect(bundled_app_gemfile.read).to match(/rack-obama/) end it "locks with the injected gems" do @@ -54,7 +54,7 @@ Usage: "bundle inject GEM VERSION" context "with source option" do it "add gem with source option in gemfile" do bundle "inject 'foo' '>0' --source #{file_uri_for(gem_repo1)}" - gemfile = bundled_app("Gemfile").read + gemfile = bundled_app_gemfile.read str = "gem \"foo\", \"> 0\", :source => \"#{file_uri_for(gem_repo1)}\"" expect(gemfile).to include str end @@ -63,14 +63,14 @@ Usage: "bundle inject GEM VERSION" context "with group option" do it "add gem with group option in gemfile" do bundle "inject 'rack-obama' '>0' --group=development" - gemfile = bundled_app("Gemfile").read + gemfile = bundled_app_gemfile.read str = "gem \"rack-obama\", \"> 0\", :group => :development" expect(gemfile).to include str end it "add gem with multiple groups in gemfile" do bundle "inject 'rack-obama' '>0' --group=development,test" - gemfile = bundled_app("Gemfile").read + gemfile = bundled_app_gemfile.read str = "gem \"rack-obama\", \"> 0\", :groups => [:development, :test]" expect(gemfile).to include str end @@ -88,7 +88,7 @@ Usage: "bundle inject GEM VERSION" it "injects anyway" do bundle "inject 'rack-obama' '> 0'" - expect(bundled_app("Gemfile").read).to match(/rack-obama/) + expect(bundled_app_gemfile.read).to match(/rack-obama/) end it "locks with the injected gems" do diff --git a/spec/commands/remove_spec.rb b/spec/commands/remove_spec.rb index 402faaf1f3..ef313928e2 100644 --- a/spec/commands/remove_spec.rb +++ b/spec/commands/remove_spec.rb @@ -54,7 +54,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" - expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.") + expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.") end end end @@ -91,7 +91,7 @@ RSpec.describe "bundle remove" do bundle "remove rails rack minitest" - expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.") + expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.") gemfile_should_be <<-G source "#{file_uri_for(gem_repo1)}" @@ -436,7 +436,7 @@ RSpec.describe "bundle remove" do bundle "remove rack" - expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.") + expect(err).to include("`rack` is not specified in #{bundled_app_gemfile} so it could not be removed.") end end |