A little less clutter / mixed concerns:
```Ruby
def with_gemfile(gemfile)
  ENV["BUNDLE_GEMFILE"], orig_gemfile = gemfile.to_s, ENV["BUNDLE_GEMFILE"]
  yield
ensure
  ENV["BUNDLE_GEMFILE"] = orig_gemfile
end
```