NameError:升级到rails3时出现未初始化常量Test::Unit::AssertionFailedError
我正在尝试将我的 Rails 应用程序升级到 Rails3。
当我运行功能测试时,我收到很多 NameError: uninitializedconstant Test::Unit::AssertionFailedError
错误。但单元测试和网站本身似乎运行良好。
Trace 看起来像这样:
NameError: uninitialized constant Test::Unit::AssertionFailedError
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/action_controller/matchers/redirect_to_matcher.rb:52:in `rescue in redirects_to_url?'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/action_controller/matchers/redirect_to_matcher.rb:48:in `redirects_to_url?'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/action_controller/matchers/redirect_to_matcher.rb:35:in `matches?'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/assertions.rb:53:in `assert_accepts'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/context.rb:324:in `block in should'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/context.rb:382:in `call'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/context.rb:382:in `block in create_test_from_should_hash'
Shoulda 和 Amazon S3 gems 都是最新版本。
有什么想法我做错了吗?
I'm trying to upgrade my rails application to Rails3.
When I run functional tests, I get a lot of NameError: uninitialized constant Test::Unit::AssertionFailedError
errors. But unit tests and website itself seems to work fine.
Trace looks like this:
NameError: uninitialized constant Test::Unit::AssertionFailedError
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/action_controller/matchers/redirect_to_matcher.rb:52:in `rescue in redirects_to_url?'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/action_controller/matchers/redirect_to_matcher.rb:48:in `redirects_to_url?'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/action_controller/matchers/redirect_to_matcher.rb:35:in `matches?'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/assertions.rb:53:in `assert_accepts'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/context.rb:324:in `block in should'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/context.rb:382:in `call'
/Users/mantas/.rvm/gems/ruby-1.9.2-p0/bundler/gems/shoulda-02520e4/lib/shoulda/context.rb:382:in `block in create_test_from_should_hash'
Both Shoulda and Amazon S3 gems are latest versions.
Any ideas what I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
已报告此问题 http://github.com/thoughtbot/shoulda/issues/issue/ 117.。
解决方法(至少让这个错误消失,不确定它是否实际上正常工作)是:
This has been reported http://github.com/thoughtbot/shoulda/issues/issue/117.
The work around (that at least makes this error go away, not sure if it actually works right) is:
Ash Berlin 的解决方案将使异常消失,但它会使任何
try
和catch
Test::Unit::AssertionFailedError
的匹配器失败。如果AssertionFailedError
是ActiveSupport::TestCase::Assertion
,并且您抛出ActiveSupport::TestCase::Assertion
,您将无法捕获它作为Test::Unit::AssertionFailedError
。他的继承关系是倒退的。相反,请将其放入您的test_helper.rb
中:Ash Berlin's solution will make the exception go away, but it will make any matchers that
try
andcatch
Test::Unit::AssertionFailedError
fail. IfAssertionFailedError
is anActiveSupport::TestCase::Assertion
, and you throw anActiveSupport::TestCase::Assertion
, you will not catch it as aTest::Unit::AssertionFailedError
. He has his inheritance relationship backwards. Instead, put this in yourtest_helper.rb
: