Skip to content

Nested 'temp' creating some unexpected behavior #101

@CharlesMcMillan

Description

@CharlesMcMillan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions