Skip to content

Commit

Permalink
Explicitly define a global source for tests
Browse files Browse the repository at this point in the history
This is in preparation for deprecating source-less gemfiles.
  • Loading branch information
daniel-niknam authored and deivid-rodriguez committed Jul 26, 2021
1 parent 422fec4 commit d6493fa
Show file tree
Hide file tree
Showing 43 changed files with 324 additions and 40 deletions.
6 changes: 3 additions & 3 deletions bundler/spec/bundler/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ def out_with_macos_man_workaround

context "with --verbose" do
it "prints the running command" do
gemfile ""
gemfile "source \"#{file_uri_for(gem_repo1)}\""
bundle "info bundler", :verbose => true
expect(out).to start_with("Running `bundle info bundler --verbose` with bundler #{Bundler::VERSION}")
end

it "doesn't print defaults" do
install_gemfile "", :verbose => true
install_gemfile "source \"#{file_uri_for(gem_repo1)}\"", :verbose => true
expect(out).to start_with("Running `bundle install --verbose` with bundler #{Bundler::VERSION}")
end

it "doesn't print defaults" do
install_gemfile "", :verbose => true
install_gemfile "source \"#{file_uri_for(gem_repo1)}\"", :verbose => true
expect(out).to start_with("Running `bundle install --verbose` with bundler #{Bundler::VERSION}")
end
end
Expand Down
4 changes: 2 additions & 2 deletions bundler/spec/bundler/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def with_clear_paths(env_var, env_value)

context "when there is a Gemfile and a lockfile and print_gemfile is true" do
before do
gemfile "gem 'rack', '1.0.0'"
gemfile "source \"#{file_uri_for(gem_repo1)}\"; gem 'rack', '1.0.0'"

lockfile <<-L
GEM
Expand Down Expand Up @@ -138,7 +138,7 @@ def with_clear_paths(env_var, env_value)
end

before do
gemfile("gemspec")
gemfile("source \"#{file_uri_for(gem_repo1)}\"; gemspec")

File.open(bundled_app.join("foo.gemspec"), "wb") do |f|
f.write(gemspec)
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/bundler/plugin/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

before do
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
gemfile ""
gemfile "source \"#{file_uri_for(gem_repo1)}\""
path = lib_path(plugin_name)
index.register_plugin("new-plugin", path.to_s, [path.join("lib").to_s], commands, sources, hooks)
end
Expand Down
8 changes: 7 additions & 1 deletion bundler/spec/cache/gems_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
shared_examples_for "when there are only gemsources" do
before :each do
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G

Expand Down Expand Up @@ -39,6 +40,7 @@
end

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G

Expand All @@ -49,6 +51,7 @@
system_gems "rack-1.0.0", :path => default_bundle_path

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G

Expand All @@ -64,6 +67,7 @@
cache_gems "rack-1.0.0"

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G

Expand Down Expand Up @@ -100,7 +104,7 @@

it "uses builtin gems when installing to system gems" do
bundle "config set path.system true"
install_gemfile %(gem 'builtin_gem', '1.0.2')
install_gemfile %(source "#{file_uri_for(gem_repo1)}"; gem 'builtin_gem', '1.0.2')
expect(the_bundle).to include_gems("builtin_gem 1.0.2")
end

Expand Down Expand Up @@ -134,6 +138,7 @@
bundle "config set path.system true"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'builtin_gem', '1.0.2'
G

Expand Down Expand Up @@ -302,6 +307,7 @@
:path => bundled_app("vendor/cache")

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo-bundler"
G

Expand Down
9 changes: 9 additions & 0 deletions bundler/spec/cache/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ref = git.ref_for("master", 11)

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G

Expand All @@ -36,6 +37,7 @@
ref = git.ref_for("master", 11)

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G

Expand All @@ -55,6 +57,7 @@
build_git "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G

Expand All @@ -72,6 +75,7 @@
old_ref = git.ref_for("master", 11)

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G

Expand Down Expand Up @@ -102,6 +106,7 @@
old_ref = git.ref_for("master", 11)

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G

Expand Down Expand Up @@ -130,6 +135,7 @@
ref = git.ref_for("master", 11)

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-invalid")}', :branch => :master
G

Expand Down Expand Up @@ -160,6 +166,7 @@
sys_exec "git commit -m \"submodulator\"", :dir => lib_path("has_submodule-1.0")

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
git "#{lib_path("has_submodule-1.0")}", :submodules => true do
gem "has_submodule"
end
Expand All @@ -183,6 +190,7 @@
update_git("foo") {|s| s.write "foo.gemspec", spec_lines.join("\n") }

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
bundle "config set cache_all true"
Expand All @@ -197,6 +205,7 @@
build_git "foo"

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
bundle "config set cache_all true"
Expand Down
12 changes: 12 additions & 0 deletions bundler/spec/cache/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
build_lib "foo", :path => bundled_app("lib/foo")

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{bundled_app("lib/foo")}'
G

Expand All @@ -18,6 +19,7 @@
build_lib "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
G

Expand All @@ -36,6 +38,7 @@
build_lib libname, :path => libpath

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "#{libname}", :path => '#{libpath}'
G

Expand All @@ -51,6 +54,7 @@
build_lib "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
G

Expand All @@ -73,6 +77,7 @@
build_lib "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
G

Expand All @@ -84,6 +89,7 @@
build_lib "bar"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "bar", :path => '#{lib_path("bar-1.0")}'
G

Expand All @@ -95,6 +101,7 @@
build_lib "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
G

Expand All @@ -107,6 +114,7 @@
build_lib "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
G

Expand All @@ -119,6 +127,7 @@
build_lib "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
G

Expand All @@ -127,6 +136,7 @@
build_lib "bar"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
gem "bar", :path => '#{lib_path("bar-1.0")}'
G
Expand All @@ -139,6 +149,7 @@
build_lib "foo"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
G

Expand All @@ -147,6 +158,7 @@
build_lib "baz"

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => '#{lib_path("foo-1.0")}'
gem "baz", :path => '#{lib_path("baz-1.0")}'
G
Expand Down
2 changes: 2 additions & 0 deletions bundler/spec/commands/binstubs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
s.executables = %w[foo]
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :git => "#{lib_path("foo")}"
G

Expand All @@ -276,6 +277,7 @@
s.executables = %w[foo]
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "foo", :path => "#{lib_path("foo")}"
G

Expand Down
3 changes: 3 additions & 0 deletions bundler/spec/commands/check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
describe "when using only scoped rubygems sources" do
before do
gemfile <<~G
source "#{file_uri_for(gem_repo2)}"
source "#{file_uri_for(gem_repo1)}" do
gem "rack"
end
Expand All @@ -343,6 +344,7 @@
end

gemfile <<~G
source "#{file_uri_for(gem_repo1)}"
source "#{file_uri_for(gem_repo4)}" do
gem "depends_on_rack"
end
Expand All @@ -355,6 +357,7 @@
expect(out).to include("The Gemfile's dependencies are satisfied")
expect(lockfile).to eq <<~L
GEM
remote: #{file_uri_for(gem_repo1)}/
specs:
GEM
Expand Down
3 changes: 3 additions & 0 deletions bundler/spec/commands/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def should_not_have_gems(*gems)
revision = revision_for(lib_path("rails"))

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}'
G

Expand Down Expand Up @@ -869,6 +870,7 @@ def should_not_have_gems(*gems)
expect(very_simple_binary_extensions_dir).to exist

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
G

Expand All @@ -878,6 +880,7 @@ def should_not_have_gems(*gems)
expect(very_simple_binary_extensions_dir).to exist

gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
G

bundle "install"
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/commands/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
end

describe "quoting" do
before(:each) { gemfile "# no gems" }
before(:each) { gemfile "source \"#{file_uri_for(gem_repo1)}\"" }
let(:long_string) do
"--with-xml2-include=/usr/pkg/include/libxml2 --with-xml2-lib=/usr/pkg/lib " \
"--with-xslt-dir=/usr/pkg"
Expand Down

0 comments on commit d6493fa

Please sign in to comment.