2011-02-03 5 views
2

Rails 2.3.5 앱을 Rails 3.0.3으로 업그레이드하고 있습니다. 하지만 내 통합 테스트 이 작동하지 않습니다. 내가 했어야 2.11 사용하고webrat 및 Rails3을 사용한 통합 테스트

require "webrat" 
require 'webrat/core/matchers' 
include Webrat::Methods 

Webrat.configure do |config| 
    config.mode = :rack 
end 

:이 오류를 받고 있어요 : 비난

NoMethodError: undefined method `content_type' for nil:NilClass 

선은 webrat에 대한

assert_select "input#artist.title.unsolved", 1 

내 test_helper.rb 것은 좋아하는이 보인다. 3 및 webrat 0.7.3을 테스트합니다. 나는 webrat와 shoulda가 Rails3와 호환된다는 것을 읽었습니다.

누구나 해결 방법은 무엇입니까?

감사합니다. 턱시도

ADDITION는 :

은 제목에서 언급 NoMethodError은 했어야에서,하지 Webrat에서 나타나는 것으로 보인다. assert_select 주변의 전체 블록 컨텍스트 여기

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' 

그리고 :

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가 진작과 레일 3에서 사용할 수 없습니다 더 이상 여기에 추적입니다. 누군가 나를 도울 수 있기를 바랍니다. !

+0

나는 assert_select 메서드를 재정의하여 오류가 webrat에서 온 것임을 알았습니다. https://webrat.lighthouseapp.com/projects/10503/tickets/395-assert_select-not-working-with-rails-300 -due-to-webrat 위의 링크에 표시된 수정 프로그램이 작동하지 않습니다. (그리고 btw, 나는 오이를 사용하지 않습니다.) 아무도 아이디어가 없습니까? 답변을위한 – 23tux

답변

1

https://github.com/joakimk/webrat에 rails3과 함께 작동하는 webrat 포크가 있습니다. 어떤 지점에서 그것은 주요 지점으로 끌어 당겨 져야합니다. 레일 2.3은 여전히이시기에 매우 인기가 있습니다.

+0

Thx! 하지만 나는 카펫 바라 대신에 카피 바라를 사용하기로 결정했습니다. 그것은 Rails3에서 잘 작동하며, 테스트는 카피 바라에 대해 다시 작성하기가 어렵지 않습니다. – 23tux