2011-02-03 12 views
2

私はRails 2.3.5アプリをRails 3.0.3にアップグレードしています。しかし、私の統合テスト は機能しません。私はshoulda 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は、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はShouldaとRailsの3では使用できません長いです。 誰かが私を助けることを願っています! thx!

+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

関連する問題