[rspec-users] Cucumber speed tips

Ben Mabey ben at benmabey.com
Sat Dec 27 12:52:33 EST 2008


On 12/27/08 1:08 AM, Mischa Fierer wrote:
> As some of us have been using cucumber for quite a while now, I may 
> not be the only one wishing his many steps ran a bit faster.
>
> Let's try to put together a quick FAQ for people looking to speed up 
> their steps.
>
> Here's my ideas:
>
> 1) Consolidate steps
> You only need to test login for each login case, not for each time you 
> are testing some sort of logged in functionality.
> In most cases you can just post to sessions/create rather than filling 
> in a login form.
>
> 1a) Don't use GivenScenario
> Instead, make one step that will quickly do what the scenario you want 
> to start at the end of does. E.g. rather than fill in a form and post 
> to a controller to create an object, just create the object in its own 
> step.
>
> 2) Use the profiler format
> I've only tried this a few times, but the profile formatting appears 
> to be useful.
>
>
> Anybody else have any tips?

3) Seed your database in your support files.  For static data that will 
be used over and over again you can save time by only inserting it once 
in your DB at the start of the run.  For example in env.rb you could say:

unless ZipCode.count == 79851
  puts "Loading all the zip code data..."
  ....
end

>
> M
> ------------------------------------------------------------------------
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list