Я обновляю приложение Rails 2.3.5 для Rails 3.0.3. Но мои интеграционные тесты не работают. Я получаю эту ошибку:Интеграционные тесты с webrat и Rails3
NoMethodError: undefined method `content_type' for nil:NilClass
Линия виноват
assert_select "input#artist.title.unsolved", 1
Мой test_helper.rb для Webrat выглядит любит это:
require "webrat"
require 'webrat/core/matchers'
include Webrat::Methods
Webrat.configure do |config|
config.mode = :rack
end
Я использую Shoulda 2.11. 3 и webrat 0.7.3 для тестирования. Я прочитал, , что webrat и shoulda совместимы с Rails3.
Кто-нибудь знает, как это исправить?
Спасибо! смокинг
Сложение:
Кажется, что NoMethodError появляется из Shoulda, а не из Webrat, как указано в названии. Вот след:
NoMethodError: undefined method `content_type' for nil:NilClass
/Users/23tux/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48:in `method_missing'
/Users/23tux/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/testing/assertions/selector.rb:605:in `response_from_page_or_rjs'
/Users/23tux/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/testing/assertions/selector.rb:213:in `assert_select'
test/integration/user_integration_test.rb:52:in `block (3 levels) in <class:UserIntegrationTest>'
/Users/23tux/.rvm/gems/[email protected]/gems/shoulda-context-1.0.0.beta1/lib/shoulda/context/context.rb:412:in `call'
/Users/23tux/.rvm/gems/[email protected]/gems/shoulda-context-1.0.0.beta1/lib/shoulda/context/context.rb:412:in `block in run_current_setup_blocks'
/Users/23tux/.rvm/gems/[email protected]/gems/shoulda-context-1.0.0.beta1/lib/shoulda/context/context.rb:411:in `each'
/Users/23tux/.rvm/gems/[email protected]/gems/shoulda-context-1.0.0.beta1/lib/shoulda/context/context.rb:411:in `run_current_setup_blocks'
/Users/23tux/.rvm/gems/[email protected]/gems/shoulda-context-1.0.0.beta1/lib/shoulda/context/context.rb:393:in `block in create_test_from_should_hash'
А вот контекст весь блок вокруг assert_select:
class SongIntegrationTest < ActionController::IntegrationTest
context "a visitor" do
context "solving a song" do
setup do
@song = Song.make
visit song_path(@song)
end
should "have two guess fields" do
assert_select "input#artist.title.unsolved", 1
assert_select "input#title.title.unsolved", 1
end
Может быть assert_select не более доступны в Rails 3 с Shoulda. Надеюсь, кто-то может мне помочь! thx!
Я узнал, что ошибка происходит от webrat, переопределяя метод assert_select: https://webrat.lighthouseapp.com/projects/10503/tickets/395-assert_select-not-working-with-rails-300 -due-to-webrat Но исправление, показанное по ссылке выше, не работает (и, кстати, я не использую огурец). У кого-нибудь есть идея? – 23tux