Should configatron.temp ensure that temp_end is called?
showaltb opened this issue · comments
If I write an RSpec example like this:
configatron.temp do
configatron.foo = "someval"
expect(something).to be_falsy
end
and the expectation fails, the temp setting "leaks" and can cause other examples to fail unexpectedly. This can be handled by setting configatron.foo to a known value in a before(:example) block, but I wonder if temp should work more like the following:
begin
configatron.temp_start
configatron.foo = "someval"
expect(something).to be_falsy
ensure
configatron.temp_end
end
Huh, yeah, I feel like temp
should always clean itself up. @markbates, do you agree? Looks like the current behavior has existed forever.
the temp block should always clean after itself. i'm surprised to hear that it's not.
looking at it looks like the temp
function does call temp_end
, but it should probably have an ensure
in there for good measure.
If a user is calling temp_start
manually, it's their responsibility to make sure temp_end
gets called.
Yeah, the missing ensure block is what surprised me. Fixing.