Skip to content

Commit a5e0e26

Browse files
committed
Avoid deprecation warning with Bundler.with_clean_env
The method is not always accessible NoMethodError: undefined method `with_unbundled_env' for Bundler:Module
1 parent e49cbab commit a5e0e26

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spec/sanity_check_spec.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77

88
before{ FileUtils.mkdir_p tmp_root }
99

10+
def bundler_env
11+
if Bundler.respond_to?(:with_unbundled_env)
12+
Bundler.with_unbundled_env { yield }
13+
else
14+
Bundler.with_clean_env { yield }
15+
end
16+
end
17+
1018
it "fails when libraries are not required" do
1119
script = tmp_root.join("fail_sanity_check")
1220
File.open(script, "w") do |f|
@@ -17,7 +25,7 @@
1725
end
1826
FileUtils.chmod 0777, script
1927

20-
Bundler.with_clean_env do
28+
bundler_env do
2129
expect(`bundle exec #{script} 2>&1`).
2230
to match(/uninitialized constant RSpec::Support/).
2331
or match(/undefined method `require_rspec_core' for RSpec::Support:Module/)
@@ -38,7 +46,7 @@
3846
end
3947
FileUtils.chmod 0777, script
4048

41-
Bundler.with_clean_env do
49+
bundler_env do
4250
expect(`bundle exec #{script} 2>&1`).to be_empty
4351
expect($?.exitstatus).to eq(0)
4452
end

0 commit comments

Comments
 (0)