Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested 'temp' creating some unexpected behavior #101

Open
CharlesMcMillan opened this issue Oct 8, 2018 · 0 comments
Open

Nested 'temp' creating some unexpected behavior #101

CharlesMcMillan opened this issue Oct 8, 2018 · 0 comments

Comments

@CharlesMcMillan
Copy link

In our tests, we make use of rspec's before/after/around lifecycle hooks to set the state of the test, including configatron settings with configatron.temp. Unfortunately when you have multiple configatron.temp competing with each other (one wrapping the other basically), it produces some results that we didn't expect:

[3] pry(main)> configatron.foo = 1
1
[4] pry(main)> configatron.temp do
[4] pry(main)*   configatron.foo = 2
[4] pry(main)*   configatron.temp do
[4] pry(main)*     configatron.foo = 3
[4] pry(main)*   end
[4] pry(main)* end
3
[5] pry(main)>
[6] pry(main)> configatron.foo
2

In this example, our our tests assumed that the settings would be returned to their original state, which in this example would be configatron.foo = 1

Is there a more elegant way to achieve what we want here with temp? In the short term, we've restored to manually holding the state of the variable we are setting and then resetting it at the end of the before/around block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant