[rspec-users] Cucumber: Before(:all)
Matt Wynne
matt at mattwynne.net
Tue Sep 2 10:53:24 EDT 2008
On 2 Sep 2008, at 15:24, aslak hellesoy wrote:
> On Tue, Sep 2, 2008 at 3:50 PM, Matt Wynne <matt at mattwynne.net> wrote:
>> Is there a way right now to run some setup code once after
>> environment.rb
>> has loaded but before all the scenarios are run?
>
> Yes. Just use Ruby :-)
>
> Put it at the "main level" in one of your ruby files under steps/
>
>> And how about a teardown after everything's done?
>
> at_exit do
> ..
> end
>
> For example:
>
> # steps/globals.rb
>
> User.create! :name => 'matt'
>
> at_exit do
> User.destroy_all
> end
>
> Would this work for you?
>
> Aslak
It looks good, but the before stuff doesn't work for me - it looks as
though the rails environment hasn't been loaded yet - I get '
uninitialized constant User (NameError)'
More information about the rspec-users
mailing list