Skip to content

Commit

Permalink
Avoid deprecation warning with Bundler.with_clean_env (#2240)
Browse files Browse the repository at this point in the history
The method is not always accessible

     NoMethodError:
       undefined method `with_unbundled_env' for Bundler:Module
  • Loading branch information
JonRowe committed Dec 18, 2019
1 parent 6d16296 commit 555f541
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions spec/sanity_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

before{ FileUtils.mkdir_p tmp_root }

def with_clean_env
if Bundler.respond_to?(:with_unbundled_env)
Bundler.with_unbundled_env { yield }
else
Bundler.with_clean_env { yield }
end
end

it "fails when libraries are not required" do
script = tmp_root.join("fail_sanity_check")
File.open(script, "w") do |f|
Expand All @@ -17,7 +25,7 @@
end
FileUtils.chmod 0777, script

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

Bundler.with_clean_env do
with_clean_env do
expect(`bundle exec #{script} 2>&1`).to be_empty
expect($?.exitstatus).to eq(0)
end
Expand Down

0 comments on commit 555f541

Please sign in to comment.