ljkbennett / stub_env

RSpec helper for stubbing ENV values
MIT License
33 stars 5 forks source link

Stubbing doesn't work with Hash#fetch #4

Closed sindrenm closed 9 years ago

sindrenm commented 9 years ago

Soeh, it looks like Hash#fetch doesn't really call [] at all.

it "gets 'pokémanz' from WHATMON, not 'digimon'" do
  ENV["WHATMON"] = "digimon"
  stub_env "WHATMON", "pokémanz"
  expect(ENV.fetch("WHATMON")).to eq "pokémanz"
end

The result:

Failure/Error: expect(ENV.fetch("WHATMON")).to eq "pokémanz"

  expected: "pokémanz"
       got: "digimon"

  (compared using ==)

However, this passes as expected (notice I've changed fetch into [] syntax:

it "gets 'pokémanz' from WHATMON, not 'digimon'" do
  ENV["WHATMON"] = "digimon"
  stub_env "WHATMON", "pokémanz"
  expect(ENV["WHATMON"]).to eq "pokémanz"
end
ljkbennett commented 9 years ago

Sorry, I missed this. Will get this fixed in the next couple of days.

ljkbennett commented 9 years ago

Just sas you had made a pr. Looks good, will release new version in next couple of days. Thanks for reporting and for fixing :smiley_cat:

ljkbennett commented 9 years ago

This is now merged and released in version 1.0.3. Thanks again.

sindrenm commented 9 years ago

Great, thanks, @littleowllabs. :grinning: