Я новичок в рельсах, и начинаю новый проект.У меня есть тесты rspec2 и cucumber без проблем.Однако, если я попытаюсь добавить guard-rspec и guard-cucumber, это приведет к сбою моих спецификаций и интеграционных тестов.Несмотря на то, что даже с установленной защитой, если я запускаю rspec и cucumber вручную, все тесты пройдут успешно.
Я добавил в свой gemfile:
gem 'guard-rspec'
gem 'guard-cucumber'
gem 'growl', :require => false if RUBY_PLATFORM =~ /darwin/i
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
Я запустил:
bundle
guard init rspec
guard init cucumber
Затем, когда я запускаю охрану, я получаю сбой rspec:
Failures:
1) PostsController GET index assigns all posts as @posts
Failure/Error: assigns(:posts).should eq([post])
expected [#<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">]
got [#<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">, #<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">, #<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">, #<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">, #<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">]
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-[#<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">]
+[#<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">, #<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">, #<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">, #<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">, #<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">]
# ./spec/controllers/posts_controller_spec.rb:29:in `block (3 levels) in <top (required)>'
И я получаю сбой огурца:
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)
Кажется, как-то Охрана портит мою фабрикуданные где-то, так как текст, начинающийся с «Тело должно быть более 50 символов», находится в моем фабричном определении factory_girl.
РЕДАКТИРОВАТЬ: Я обнаружил, что существуют различия в том, как рейквызов rspec, против охраны.Почему это так?
Rake:
/ 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.rbs..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
Guard:
/ Пользователи / 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 / matta.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/запросы / 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 '