Skip to content

Commit d04f187

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Refactor git specs
To save some unnecessary `bundle install` commands. ruby/rubygems@61e7d9d09a
1 parent 4a3a544 commit d04f187

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

spec/bundler/install/gemfile/git_spec.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe "bundle install with git sources" do
44
describe "when floating on main" do
5-
before :each do
5+
let(:install_base_gemfile) do
66
build_git "foo" do |s|
77
s.executables = "foobar"
88
end
@@ -16,6 +16,7 @@
1616
end
1717

1818
it "fetches gems" do
19+
install_base_gemfile
1920
expect(the_bundle).to include_gems("foo 1.0")
2021

2122
run <<-RUBY
@@ -27,16 +28,19 @@
2728
end
2829

2930
it "caches the git repo" do
31+
install_base_gemfile
3032
expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes size: 1
3133
end
3234

3335
it "does not write to cache on bundler/setup" do
36+
install_base_gemfile
3437
FileUtils.rm_r(default_cache_path)
3538
ruby "require 'bundler/setup'"
3639
expect(default_cache_path).not_to exist
3740
end
3841

3942
it "caches the git repo globally and properly uses the cached repo on the next invocation" do
43+
install_base_gemfile
4044
pristine_system_gems
4145
bundle "config set global_gem_cache true"
4246
bundle :install
@@ -48,6 +52,7 @@
4852
end
4953

5054
it "caches the evaluated gemspec" do
55+
install_base_gemfile
5156
git = update_git "foo" do |s|
5257
s.executables = ["foobar"] # we added this the first time, so keep it now
5358
s.files = ["bin/foobar"] # updating git nukes the files list
@@ -66,6 +71,7 @@
6671
end
6772

6873
it "does not update the git source implicitly" do
74+
install_base_gemfile
6975
update_git "foo"
7076

7177
install_gemfile bundled_app2("Gemfile"), <<-G, dir: bundled_app2
@@ -84,6 +90,7 @@
8490
end
8591

8692
it "sets up git gem executables on the path" do
93+
install_base_gemfile
8794
bundle "exec foobar"
8895
expect(out).to eq("1.0")
8996
end
@@ -136,7 +143,7 @@
136143

137144
it "still works after moving the application directory" do
138145
bundle "config set --local path vendor/bundle"
139-
bundle "install"
146+
install_base_gemfile
140147

141148
FileUtils.mv bundled_app, tmp("bundled_app.bck")
142149

@@ -145,7 +152,7 @@
145152

146153
it "can still install after moving the application directory" do
147154
bundle "config set --local path vendor/bundle"
148-
bundle "install"
155+
install_base_gemfile
149156

150157
FileUtils.mv bundled_app, tmp("bundled_app.bck")
151158

0 commit comments

Comments
 (0)