[rspec-users] Any plans for Before-feature or Before-all steps in Cucumber?
josephwilk at joesniff.co.uk
Tue Dec 2 10:26:52 EST 2008
Ashley Moran wrote:
> The code I'm working on now is a server daemon that talks to Twitter,
> an RSS feed, and some web pages. I've got mock implementations of
> Twitter and the web stuff, which I start and stop with
> daemon_controller. I do all the setup in a Before block,
All defined before blocks are run for each scenario so this would slow
down every scenario.
> but this makes the feature runs agonisingly slow due to the time
> waiting for everything to restart. I'm now starting a Merb app which
> will rely on the database created by the server daemon, so it's going
> to get even slower.
> Are there any plans to add BeforeStory or BeforeAll blocks to
> Cucumber? With this I could start everything once and add reset code
> to each daemon.
BeforeAll (Before running any feature) is currently possible through
putting something in your env.rb or really any ruby file that gets
required. It will be run once (and before anything else).
I use this to manage ferret/selenium. The before/afters being used to
tell the service to cleanup so we have clean environment for each test.
Could you do the same?
And Afterall is possible through: at_exit
BeforeFeature sounds like it could be useful for preparing services for
that specific feature and you don't want them running for other
features. I guess currently the only way of achieving this is
separating those features and running them in separate cucumber runs.
This is what I have done with something similar, using --profile to run
different sets of features. I prefer this (in my experience so far) as
it allows me to re-use my rake tasks for setting things up and keeps
that setup from adding noise to my test code. I appreciate with mock
services your situation is slightly different.
More information about the rspec-users