Shoulda equivalent of RSpec's before(:all)

22 views
Skip to first unread message

Kyle Fox

unread,
Nov 3, 2009, 6:06:18 PM11/3/09
to shoulda
I have to unit test a model which has associations to some other
models which are expensive to create. They are currently being
created inside my `setup`, but since this gets executed before every
single `should` statement, my tests take an excruciating amount of
time to run.

I'm looking for a way to initialize these objects exactly once, and
have them persist throughout the entire test case. RSpec's `before
(:all)` method[1] is exactly what I'm looking for. I'm not concerned
about the dependencies this method creates because my tests will not
modify the associated objects.

I've created a gist that hopefully illustrates my scenario.[2]

Thanks,
Kyle.

[1] http://rspec.info/documentation/
[2] http://gist.github.com/225513

Dan Croak

unread,
Nov 11, 2009, 4:50:47 PM11/11/09
to sho...@googlegroups.com
This might be what you're looking for:

http://m.onkey.org/2009/9/20/make-your-shoulda-tests-faster-with-fast_context

I haven't used it, though. I'm curious to hear some success or failure
stories about it.
--
Dan Croak
@Croaky
Reply all
Reply to author
Forward
0 new messages