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:
Create an app with
rails new cucumber_test -T
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.)Run the Cucumber generator:
rails g cucumber:install
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.