質問

Ruby 1.9とRails 2.3.5で空白のデフォルトパフォーマンステストを実行しようとしていますが、機能させることはできません。ここで何が欠けていますか?

rails testapp
cd testapp
script/generate scaffold User name:string
rake db:migrate
rake test:benchmark

-

/usr/local/bin/ruby19 -I"lib:test" "/usr/local/lib/ruby19/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/performance/browsing_test.rb" -- --benchmark
Loaded suite /usr/local/lib/ruby19/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
/usr/local/lib/ruby19/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `rescue in const_missing': uninitialized constant BrowsingTest::STARTED (NameError)
    from /usr/local/lib/ruby19/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:94:in `const_missing'
    from /usr/local/lib/ruby19/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/testing/performance.rb:38:in `run'
    from /usr/local/lib/ruby19/1.9.1/minitest/unit.rb:415:in `block (2 levels) in run_test_suites'
    from /usr/local/lib/ruby19/1.9.1/minitest/unit.rb:409:in `each'
    from /usr/local/lib/ruby19/1.9.1/minitest/unit.rb:409:in `block in run_test_suites'
    from /usr/local/lib/ruby19/1.9.1/minitest/unit.rb:408:in `each'
    from /usr/local/lib/ruby19/1.9.1/minitest/unit.rb:408:in `run_test_suites'
    from /usr/local/lib/ruby19/1.9.1/minitest/unit.rb:388:in `run'
    from /usr/local/lib/ruby19/1.9.1/minitest/unit.rb:329:in `block in autorun'
rake aborted!
Command failed with status (1): [/usr/local/bin/ruby19 -I"lib:test" "/usr/l...]
役に立ちましたか?

解決

見る これ。パッチについては、参照してください ここ.

他のヒント

OK、問題は、Ruby 1.8がデフォルトのテストライブラリとしてテスト::ユニットを使用したことです。 Ruby 1.9では、Minitestに変更されました。

3.1.0の前のActiveSupportのバージョンは、テスト::ユニットを想定しています。 3.1.0以降で対処されているようです。ただし、Rails 3.0.9を使用している場合、Activesupport 3.0.9に依存しているため、Gemfileで後のバージョンを要求することはできません。

見つかった これ Google経由。どうやら、テスト::ユニットライブラリはまだ利用可能ですが、「テストユニット」という名前の宝石として。

それで、Rails Gemの前に上の私のgemfileで、私は言います:

gem 'test-unit', '~> 2.3.0'

それから私はレーキテストを実行しました:ベンチマークとそれはうまくいきました!

バグだと思います。 Ruby 1.8.6(2008-08-11 Patchlevel 287)[Universal-Darwin9.0]でコードを実行できます。 Ruby 1.9.1の下で、私はあなたが説明するような例外を取得します。

ActiveSupport :: Testing :: Performance#run(Rails)に達すると、ラインで例外が発生します yield(self.class::STARTED, name) 定数を見つけようとする場所:: START。 Ruby Profにも同様の方法があり、RubyProf :: test#runがあります。

ここで誰が責任を負っているのかわかりません。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top