我正在尝试使用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...]
有帮助吗?

解决方案

这个。对于补丁,请参阅 这里.

其他提示

好的,问题是Ruby 1.8使用了Test ::单元作为其默认测试库。在Ruby 1.9中,它已更改为最耗尽。

3.1.0之前的ActiveSupport版本假定测试::单元。看起来它已在3.1.0和更高版本中解决。如果您使用的是Rails 3.0.9,则它对ActiveSuppport 3.0.9具有依赖性,因此您不能在Gemfile中要求以后的版本。

成立 这个 通过Google。显然,Test ::单元库仍然可用,但作为“ Test-Unit”的宝石。

因此,在铁轨宝石之前的我的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(在铁轨中)时会在线上例外 yield(self.class::STARTED, name) 它试图找到常数::开始的位置。 Ruby Prof也有类似的方法,在RubyProf ::测试#运行下。

我不知道谁在这里有错。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top