Ruby 1.9.3 破坏了 rake 测试
我有一个现有的 Rails 3 项目,它在 ruby 1.9.2-p290 上运行得很好。然而,升级到 ruby 1.9.3-p0 会导致 rake test
吐出以下错误:
/Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: test/unit/**/*_test.rb (ArgumentError)
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:21:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
/Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: test/functional/**/*_test.rb (ArgumentError)
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:21:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
这似乎是 rake 问题。但是,当我在 ruby 1.9.3 上创建一个简单的 Rails 项目时,就会发生这样的错误。我该怎么做才能让我的 Rails 项目在 ruby 1.9.3 上运行?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
添加测试单元 gem 对我有用。
Adding the test-unit gem worked for me.
尝试以下操作(独立):
test.test_files = FileList['test/unit/**/test*.rb']
shoulda
beta 依赖项。test/unit
gem。Try the following (independently):
test.test_files = FileList['test/unit/**/test*.rb']
shoulda
beta dependency.test/unit
gem.在 ruby 1.9.3 的测试环境中使用
rake
时,shoulda
gem 会导致一个普遍问题,这在 此问题。解决方法
使用这一行
您可以在 Gemfile 中
,然后在测试代码中的某个位置(例如
test/test_helper.rb
如果您使用的是测试单元),您可以将If you are using rspec you should not use根本没有shoulda
gem,您应该使用shoulda-matchers
这不会导致问题。The
shoulda
gem is causing a general problem when usingrake
in test environment on ruby 1.9.3, this is repported in this issue.Workaround
You can use this line
in your Gemfile and then somewhere in your test code (e.g.
test/test_helper.rb
if you are using test-unit) you can putIf you are using rspec you should not use the
shoulda
gem at all, you should use theshoulda-matchers
and this will not cause problems.我们将 rake 任务(rake 文件)更改为如下所示
: http://rake .rubyforge.org/classes/Rake/TestTask.html
We changed our rake task (rake file) to look like this
based upon: http://rake.rubyforge.org/classes/Rake/TestTask.html