2011-01-11 8 views
0

deviseでパフォーマンステストを実行するにはどうすればよいですか。 Functional testing with Rails and Devise. What to put in my fixtures?から私のtest_helper.rbdevise認証によるパフォーマンステスト

class ActionController::TestCase 
    include Devise::TestHelpers 
end 

に私はこれを持って考案のドキュメントを使用して、私は私の性能試験でこれを持っている:

require 'test_helper' 
require 'rails/performance_test_help' 

class EditorTest < ActionDispatch::PerformanceTest 

    def test_create 

    @user = users(:one) 
    sign_in @user 

    get 'documents/new/1' 
    end 

end 

私は、取得するには、次のエラー

NoMethodError: undefined method `sign_in' for #<EditorTest:0xb6bc0654 ...> 
    /test/performance/editor_test.rb:9:in `test_create' 

方法Devise TestHelpersをパフォーマンステストに適切に含めるにはどうすればよいですか?

ありがとうございました!

[編集]

これは機能テストとして機能します。

/usr/lib/ruby/gems/1.8/gems/devise-1.1.rc2/lib/devise/test_helpers.rb: 

53: warning: instance variable @request not initialized 
Exception `NoMethodError' at /usr/lib/ruby/gems/1.8/gems/ 
activesupport-3.0.3/lib/active_support/whiny_nil.rb:48 - undefined 
method `env' for nil:NilClass 
EEditorTest#test_create (0 ms warmup) 
/usr/lib/ruby/gems/1.8/gems/devise-1.1.rc2/lib/devise/test_helpers.rb: 

53: warning: instance variable @request not initialized 
Exception `NoMethodError' at /usr/lib/ruby/gems/1.8/gems/ 
activesupport-3.0.3/lib/active_support/whiny_nil.rb:48 - undefined 
method `env' for nil:NilClass 
E  process_time: 0 ms 
Exception `Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - 

File exists - tmp/performance Exception Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/performance Exception Errno::EEXIST' at /usr/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/performance

の短いバージョン:

[編集]

ActionDispatch :: PerformanceTestで工夫ヘルパーを含むとルビー-dを使用してテストを実行した後、ここでのデバッグ出力の底があります上記のエラー:

NoMethodError: undefined method `env' for nil:NilClass 

答えて

1

パフォーマンステストでは、Deviseテストヘルパーがアクセスしようとする変数requestが設定されていないようです。言い換えれば、Deviseテストのヘルパーはここであなたを助けません。

http://groups.google.com/group/plataformatec-devise/browse_thread/thread/b50bfd8ecb24822c統合テストのようにサインインフォームを記入してください。

これは、統合テストはどのように署名する例で、どのように動作するかを説明します。それは一番下にありますhttp://guides.rubyonrails.org/testing.html#integration-testing

+0

デビッドとホセありがとう! – joshs

2

(間違った質問への誤読質問元の回答は以下の通りです。)

あなたのヘルパーファイルの一番下に

class ActionDispatch::PerformanceTest 
    include Devise::TestHelpers 
end 

を追加

してみてください。


は(オリジナルの返信)

class ActionController::TestCase 
    include Devise::TestHelpers 
end 

ていることを確認してくださいあなたのヘルパーファイルの一番下にあるすべての方法です。それはActiveSupport::TestCaseクラス内にあってはなりません。

+0

。機能テストは既に機能しています。それは単なるパフォーマンステストです。 – joshs

+0

更新された返信をご覧ください。 –

+0

上記の私の編集を参照してください。あなたの提案から、部分的なデバッグ出力とともにエラーを投稿しました。 – joshs

関連する問題