1

I'd like to use Cucumber via Rake for BDD in a Rails 4. I've got it installed and hooked into spring to speed up tests but they take much longer than expected to run. The tests definitively run faster when Spring is active, but there is always ~2 seconds of startup time for Cucumber even if there are no feature/scenarios to run. For example:

$ bin/spring status
Spring is not running.

$ time bin/rake cucumber
/Users/alans/.rvm/rubies/ruby-2.1.1/bin/ruby -S bundle exec cucumber  --profile default
Using the default profile...
0 scenarios
0 steps
0m0.000s
bin/rake cucumber  0.08s user 0.02s system 3% cpu 3.463 total

$ bin/spring status
Spring is running:
64383 spring server | cucumber_test | started 48 secs ago
64384 spring app    | cucumber_test | started 48 secs ago | test mode    

$ time bin/rake cucumber
/Users/alans/.rvm/rubies/ruby-2.1.1/bin/ruby -S bundle exec cucumber  --profile default
Using the default profile...
0 scenarios
0 steps
0m0.000s
bin/rake cucumber  0.08s user 0.02s system 4% cpu 2.098 total

Using bin/rake for the run is what's defined in the Spring Readme. Running spring without rake produces the faster expected times.

$ time spring cucumber
Using the default profile...
0 scenarios
0 steps
0m0.000s
spring cucumber  0.06s user 0.01s system 13% cpu 0.537 total

The Question

How can I setup Cucumber, Spring and Rake so that tests run as quickly with Rake as without?



Further Details

My environment is an RVM install of ruby-2.1.1 and rails 4.1.1 on a Mac with an SSD running 10.9.3.

Here's what I'm doing:

  1. Create an app with

    rails new cucumber_test -T
    
  2. Update the gem file with the following:

    group :development, :test do
    
      gem 'cucumber-rails', :require => false
      gem 'database_cleaner'
      gem 'rspec-rails'
      gem 'spring'
      gem 'spring-commands-cucumber'
    
    end
    

    Then running:

    bundle install
    

    (I also tried leaving the default listing for spring in just the :development environment but that didn't speed things up either.)

  3. Run the Cucumber generator:

    rails g cucumber:install
    
  4. Update the Spring binstubs:

    bundle exec spring binstub --all
    

    Which returns:

    * bin/rake: spring already present
    * bin/cucumber: generated with spring 
    * bin/rails: spring already present
    

This is where I run the time tests. When Spring is stopped, Cucumber consistently takes longer to run. Even with Spring running it seems there is always a 2 second overhead before the test suite actually kicks off when using Rake. That's what I'm trying to eliminate.

Baldrick
  • 23,882
  • 6
  • 74
  • 79
Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
  • why not just use spring cucumber? – phoet Jun 14 '14 at 20:22
  • I'd like to use rake so both Cucumber and RSpec tests can be run with a single command. – Alan W. Smith Jun 15 '14 at 14:11
  • I find, to my alarm, that `bin/rake cucumber` takes the same amount of time with or without spring. Editing the generated cucumber tasks to set `fork = false` saves me 2.5s with or without spring. `bin/cucumber` without spring is about as fast as `bin/rake cucumber` with `fork=false` and with or without without spring. `bin/cucumber` with spring is a couple of seconds faster than that, so even with `fork = false` rake is taking a couple of extra seconds. – Dave Schweisguth Jun 18 '14 at 22:56

0 Answers0