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

Already on GitHub? Sign in to your account

RSpec.world.reset does not reset shared_example_groups #27

Closed
pbiggar opened this Issue Jan 25, 2012 · 6 comments

Comments

Projects
None yet
2 participants

pbiggar commented Jan 25, 2012

It resets example_groups, but not shared ones. I reckon a fix is to just add a line to World.reset to clear it. Does that seem right? Should I submit a pull request for that?

Contributor

justinko commented Jan 25, 2012

Thanks, but shared_example_groups doesn't need to be cleared :)

@justinko justinko closed this Jan 25, 2012

pbiggar commented Jan 25, 2012

Ah, I should describe my use case more.

So it only doesn't need to be cleared if you assume that the Ruby runtime will only be initialized once in the program. However, because of the slow startup time in JRuby, we use a single VM and run RSpec multiple times in that VM by calling RSpec::Core::Runner.run. Perhaps there's a better way to use RSpec?

Contributor

justinko commented Jan 25, 2012

This use case is why example_groups.clear exists. Even with multiple runs, clearing shared_example_groups would have no affect on your expectations, right?

pbiggar commented Jan 25, 2012

With multiple runs, I get an error like "Shared example group 'an email' already exists". Clearing shared_example_groups fixes that.

Contributor

justinko commented Jan 25, 2012

Ahhhh I forgot about that check. Pushing a fix.

Contributor

justinko commented Jan 25, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment