2010-09-07 20 views
5

Tôi đang cố gắng nâng cấp ứng dụng đường ray của mình lên Rails3.NameError: uninitialized constant Test :: Unit :: AssertionFailedError khi nâng cấp lên đường ray3

Khi tôi chạy thử nghiệm chức năng, tôi nhận được rất nhiều lỗi NameError: uninitialized constant Test::Unit::AssertionFailedError. Nhưng các bài kiểm tra đơn vị và trang web của chính nó dường như hoạt động tốt.

vết trông như thế này:

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' 

Cả shoulda và Amazon S3 đá quý là phiên bản mới nhất.

Bất kỳ ý tưởng nào tôi đang làm sai?

Trả lời

6

Điều này đã được báo cáo http://github.com/thoughtbot/shoulda/issues/issue/117.

Công việc xung quanh (ít nhất làm cho lỗi này đi, không chắc chắn nếu nó thực công trình phải) là:

unless defined?(Test::Unit::AssertionFailedError) 
    class Test::Unit::AssertionFailedError < ActiveSupport::TestCase::Assertion 
    end 
end 
+0

Rất tiếc - tôi quên metion, tôi đặt đoạn mã đó trong bài kiểm tra/test_helper.rb –

6
giải pháp

Ash Berlin sẽ làm cho ngoại lệ đi xa, nhưng nó sẽ làm cho bất kỳ đối sánh nào mà trycatchTest::Unit::AssertionFailedError không thành công. Nếu AssertionFailedError là một số ActiveSupport::TestCase::Assertion và bạn ném một số ActiveSupport::TestCase::Assertion, bạn sẽ không xem số này là Test::Unit::AssertionFailedError. Anh ta có mối quan hệ thừa kế của mình về phía sau. Thay vào đó, hãy đặt mã này vào trong test_helper.rb:

unless defined?(Test::Unit::AssertionFailedError) 
    Test::Unit::AssertionFailedError = ActiveSupport::TestCase::Assertion 
end