title: Why does guard cause my tests to fail?
body: <p>I'm new to rails, and starting a new project.  I have rspec2 and cucumber working with my tests with no problem.  However, if I try to add guard-rspec and guard-cucumber, it causes both my specs and integration tests to fail.  Although, even with guard installed, if I run rspec and cucumber manually, the tests all succeed.</p>
  
  <p>I've added to my gemfile:</p>
  
  <pre><code>gem 'guard-rspec'
  gem 'guard-cucumber'
  gem 'growl', :require =&gt; false if RUBY_PLATFORM =~ /darwin/i
  gem 'rb-fsevent', :require =&gt; false if RUBY_PLATFORM =~ /darwin/i
  </code></pre>
  
  <p>I ran:</p>
  
  <pre><code>bundle
  guard init rspec
  guard init cucumber
  </code></pre>
  
  <p>Then when I run guard, I get rspec failing:</p>
  
  <pre><code>Failures:
  
    1) PostsController GET index assigns all posts as @posts
       Failure/Error: assigns(:posts).should eq([post])
  
         expected [#&lt;Post id: 14, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 19:02:46"&gt;]
              got [#&lt;Post id: 1, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 2, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 3, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 4, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 5, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;]
  
         (compared using ==)
  
         Diff:
         @@ -1,2 +1,2 @@
         -[#&lt;Post id: 14, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 19:02:46"&gt;]
         +[#&lt;Post id: 1, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 2, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 3, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 4, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;, #&lt;Post id: 5, title: "Title", body: "The body must be over 50 characters long, or else i...", created_at: "2011-08-16 09:02:26", updated_at: "2011-08-17 18:56:51"&gt;]
       # ./spec/controllers/posts_controller_spec.rb:29:in `block (3 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>And I get cucumber failing:</p>
  
  <pre><code>Running all features
  Disabling profiles...
  ..F-----------
  
  (::) failed steps (::)
  
  expected there to be content "Test Title" in "Listing posts\n\nTitle\n    Body\n    Created at\n    \n    \n    \n  Title\n    The body must be over 50 characters long, or else it will fail validation.  This string should be adequate.\n    2011-08-16 09:02:26 UTC\n    Show\n    Edit\n    Destroy\n  Title\n    The body must be over 50 characters long, or else it will fail validation.  This string should be adequate.\n    2011-08-16 09:02:26 UTC\n    Show\n    Edit\n    Destroy\n  Title\n    The body must be over 50 characters long, or else it will fail validation.  This string should be adequate.\n    2011-08-16 09:02:26 UTC\n    Show\n    Edit\n    Destroy\n  Title\n    The body must be over 50 characters long, or else it will fail validation.  This string should be adequate.\n    2011-08-16 09:02:26 UTC\n    Show\n    Edit\n    Destroy\n  Title\n    The body must be over 50 characters long, or else it will fail validation.  This string should be adequate.\n    2011-08-16 09:02:26 UTC\n    Show\n    Edit\n    Destroy\n  ← Previous 1 2 3 4 5 6 Next →\n\nNew Post\n\n\n" (RSpec::Expectations::ExpectationNotMetError)
  ./features/step_definitions/web_steps.rb:107:in `/^(?:|I )should see "([^"]*)"$/'
  features/Homepage.feature:17:in `Then I should see "Test Title"'
  
  Failing Scenarios:
  cucumber features/Homepage.feature:6 # Scenario: Viewing the index page with paging
  
  1 scenario (1 failed)
  14 steps (1 failed, 11 skipped, 2 passed)
  </code></pre>
  
  <p>It seems like somehow Guard is messing with my factory data somewhere, since the text starting with "The body must be over 50 characters" is in my factory_girl factory definition.</p>
  
  <p><strong>EDIT:</strong>
  I've found that there are differences in how rake is calling rspec, vs guard.  Why would this be?</p>
  
  <p>Rake:</p>
  
  <blockquote>
    <p>/Users/mandreko/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S bundle exec
    rspec ./spec/controllers/posts_controller_spec.rb
    ./spec/controllers/tags_controller_spec.rb
    ./spec/helpers/posts_helper_spec.rb ./spec/helpers/tags_helper_spec.rb
    ./spec/models/post_spec.rb ./spec/models/tag_spec.rb
    ./spec/requests/posts_spec.rb ./spec/requests/tags_spec.rb
    ./spec/routing/posts_routing_spec.rb
    ./spec/routing/tags_routing_spec.rb
    ./spec/views/posts/edit.html.erb_spec.rb
    ./spec/views/posts/index.html.erb_spec.rb
    ./spec/views/posts/new.html.erb_spec.rb
    ./spec/views/posts/show.html.erb_spec.rb
    ./spec/views/tags/edit.html.erb_spec.rb
    ./spec/views/tags/index.html.erb_spec.rb
    ./spec/views/tags/new.html.erb_spec.rb
    ./spec/views/tags/show.html.erb_spec.rb</p>
  </blockquote>
  
  <p>Guard:</p>
  
  <blockquote>
    <p>/Users/mandreko/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -rrubygems -S
    /Users/mandreko/.rvm/gems/ruby-1.9.2-p290@rails31rc5/gems/rspec-core-2.6.4/bin/rspec
    --tty
    '/Users/mandreko/Documents/mattandreko.com/spec/controllers/posts_controller_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/controllers/tags_controller_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/helpers/posts_helper_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/helpers/tags_helper_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/posts/edit.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/posts/index.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/posts/new.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/posts/show.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/tags/edit.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/tags/index.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/tags/new.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/views/tags/show.html.erb_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/models/post_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/models/tag_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/requests/posts_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/requests/tags_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/routing/posts_routing_spec.rb'
    '/Users/mandreko/Documents/mattandreko.com/spec/routing/tags_routing_spec.rb'</p>
  </blockquote>