OK - I found a workaround. I simply tag the first scenario with
'@first', then
do Before('@first') and i get what I want - executing a block once for
the feature file.
Except for one problem: most of my scenarios are done as scenario
outlines, which
are run multiple times - once for each row of my Example table.
A workaround to that problem might be to put a 'dummy' scenario that
is run before the other scenarios in my feature file...
@first
Scenario: Call a before block before running other scenarios...
But this puts junk in my feature files. Is there a better, cleaner
way??
On Apr 28, 8:32 am, Arco <[email protected]> wrote:
> I also would like a hook that executes a block once before running a
> feature file.
>
> In my testing i found that:
> - Background: executes before each scenario
> - Before executes before each scenario
> - Before('@tag') executes before each scenario
>
> Is there a way to execute a block once before each feature, but not
> before each scenario?
>
> On Apr 28, 7:08 am, aslak hellesoy <[email protected]> wrote:
>
> > > Hi -- is it possible to set before and after blocks for individual feature
> > > files?
>
> > Yes. Use tagged hooks:http://wiki.github.com/aslakhellesoy/cucumber/hooks
>
> > Aslak
>
> > > I've tried putting them in step files, but they just get called before
> > > everything, like they'd been declared in env.rb, which is consistent with
> > > how I thought cucumber worked, but I thought I'd best try it anyway.
> > > Anyway, I have some features that require a specific state be set up
> > > before
> > > they run -- is this possible to do, and how would I go about doing it?
> > > Thanks for any & all help,
> > > Doug.
>
> > > _______________________________________________
> > > rspec-users mailing list
> > > [email protected]
> > >http://rubyforge.org/mailman/listinfo/rspec-users
>
> > _______________________________________________
> > rspec-users mailing list
> > [email protected]http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> [email protected]http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users