summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-11 13:50:21 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-12 16:31:06 +0100
commitd4b6a4164ac7fac1de4c352a04e80dfd8b3a601a (patch)
treef595fa91f100d8c26bcc5dd3cf69b2c21287dc2c
parent2c26c8c2f3b2d8c68c2170ba06193b1d13847738 (diff)
downloadbundler-d4b6a4164ac7fac1de4c352a04e80dfd8b3a601a.tar.gz
Extract `bundled_app_gemfile` path helper
-rw-r--r--spec/bundler/cli_spec.rb4
-rw-r--r--spec/bundler/dsl_spec.rb4
-rw-r--r--spec/bundler/plugin_spec.rb2
-rw-r--r--spec/commands/add_spec.rb36
-rw-r--r--spec/commands/init_spec.rb6
-rw-r--r--spec/commands/inject_spec.rb12
-rw-r--r--spec/commands/remove_spec.rb6
-rw-r--r--spec/install/path_spec.rb4
-rw-r--r--spec/runtime/setup_spec.rb4
-rw-r--r--spec/support/matchers.rb2
-rw-r--r--spec/support/path.rb4
11 files changed, 44 insertions, 40 deletions
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index cafb5579c1..561f471687 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -93,7 +93,7 @@ RSpec.describe "bundle executable" do
context "when ENV['BUNDLE_GEMFILE'] is set to an empty string" do
it "ignores it" do
- gemfile bundled_app("Gemfile"), <<-G
+ gemfile bundled_app_gemfile, <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G
@@ -106,7 +106,7 @@ RSpec.describe "bundle executable" do
context "when ENV['RUBYGEMS_GEMDEPS'] is set" do
it "displays a warning" do
- gemfile bundled_app("Gemfile"), <<-G
+ gemfile bundled_app_gemfile, <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index 8252367f99..56a5bfdb48 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -271,7 +271,7 @@ RSpec.describe Bundler::Dsl do
describe "syntax errors" do
it "will raise a Bundler::GemfileError" do
gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
- expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
+ expect { Bundler::Dsl.evaluate(bundled_app_gemfile, nil, true) }.
to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`:( compile error -)? unknown regexp options - trg.+ Bundler cannot continue./)
end
end
@@ -279,7 +279,7 @@ RSpec.describe Bundler::Dsl do
describe "Runtime errors" do
it "will raise a Bundler::GemfileError" do
gemfile "raise RuntimeError, 'foo'"
- expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
+ expect { Bundler::Dsl.evaluate(bundled_app_gemfile, nil, true) }.
to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`: foo. Bundler cannot continue./i)
end
end
diff --git a/spec/bundler/plugin_spec.rb b/spec/bundler/plugin_spec.rb
index e0e2e9afdf..cb6012da45 100644
--- a/spec/bundler/plugin_spec.rb
+++ b/spec/bundler/plugin_spec.rb
@@ -107,7 +107,7 @@ RSpec.describe Bundler::Plugin do
describe "evaluate gemfile for plugins" do
let(:definition) { double("definition") }
let(:builder) { double("builder") }
- let(:gemfile) { bundled_app("Gemfile") }
+ let(:gemfile) { bundled_app_gemfile }
before do
allow(Plugin::DSL).to receive(:new) { builder }
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
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 5240c5820c..89a441d0f4 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe "bundle install" do
it "installs the standalone bundle relative to the cwd" do
Dir.chdir(bundled_app.parent) do
- bundle! :install, :gemfile => bundled_app("Gemfile"), :standalone => true
+ bundle! :install, :gemfile => bundled_app_gemfile, :standalone => true
expect(out).to include("installed into `./bundled_app/bundle`")
expect(bundled_app("bundle")).to be_directory
expect(bundled_app("bundle/ruby")).to be_directory
@@ -73,7 +73,7 @@ RSpec.describe "bundle install" do
bundle! "config unset path"
Dir.chdir(bundled_app("subdir").tap(&:mkpath)) do
- bundle! :install, :gemfile => bundled_app("Gemfile"), :standalone => true
+ bundle! :install, :gemfile => bundled_app_gemfile, :standalone => true
expect(out).to include("installed into `../bundle`")
expect(bundled_app("bundle")).to be_directory
expect(bundled_app("bundle/ruby")).to be_directory
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index e06e877ff9..7ffddbd151 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -866,7 +866,7 @@ end
G
Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
+ run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app_gemfile.to_s }
require 'foo'
R
end
@@ -890,7 +890,7 @@ end
bundle :install
Dir.chdir(bundled_app.parent) do
- run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s }
+ run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app_gemfile.to_s }
require 'foo'
R
end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 37461901fc..87f1326448 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -218,7 +218,7 @@ module Spec
end
def gemfile_should_be(expected)
- expect(bundled_app("Gemfile")).to read_as(strip_whitespace(expected))
+ expect(bundled_app_gemfile).to read_as(strip_whitespace(expected))
end
end
end
diff --git a/spec/support/path.rb b/spec/support/path.rb
index 7d3c96ea02..3de269d91a 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -96,6 +96,10 @@ module Spec
bundled_app("vendor/cache/#{path}.gem")
end
+ def bundled_app_gemfile
+ bundled_app("Gemfile")
+ end
+
def bundled_app_lock
bundled_app("Gemfile.lock")
end