title: Speed up Rake Cucumber test run in Rails 4
body: <p>I'd like to use Cucumber via Rake for BDD in a Rails 4. I've got it installed and hooked into <code>spring</code> 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:</p>
  
  <pre><code>$ 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
  </code></pre>
  
  <p>Using <code>bin/rake</code> for the run is what's defined in the <a href="https://github.com/rails/spring#usage" rel="nofollow">Spring Readme</a>. Running spring without rake produces the faster expected times. </p>
  
  <pre><code>$ 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
  </code></pre>
  
  <hr>
  
  <h2>The Question</h2>
  
  <p><strong>How can I setup Cucumber, Spring and Rake so that tests run as quickly with Rake as without?</strong></p>
  
  <hr>
  
  <hr>
  
  <p><strong>Further Details</strong></p>
  
  <p>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. </p>
  
  <p>Here's what I'm doing:</p>
  
  <ol>
  <li><p>Create an app with</p>
  
  <pre><code>rails new cucumber_test -T
  </code></pre></li>
  <li><p>Update the gem file with the following:</p>
  
  <pre><code>group :development, :test do
  
    gem 'cucumber-rails', :require =&gt; false
    gem 'database_cleaner'
    gem 'rspec-rails'
    gem 'spring'
    gem 'spring-commands-cucumber'
  
  end
  </code></pre>
  
  <p>Then running: </p>
  
  <pre><code>bundle install
  </code></pre>
  
  <p>(<em>I also tried leaving the default listing for <code>spring</code> in just the :development environment but that didn't speed things up either.</em>)</p></li>
  <li><p>Run the Cucumber generator:</p>
  
  <pre><code>rails g cucumber:install
  </code></pre></li>
  <li><p>Update the Spring binstubs:</p>
  
  <pre><code>bundle exec spring binstub --all
  </code></pre>
  
  <p>Which returns:</p>
  
  <pre><code>* bin/rake: spring already present
  * bin/cucumber: generated with spring 
  * bin/rails: spring already present
  </code></pre></li>
  </ol>
  
  <p>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. </p>