Getting uninitialized constant error when trying to run tests

后端 未结 12 2221
礼貌的吻别
礼貌的吻别 2020-12-10 13:29

I just updated all my gems and I\'m finding that I\'m getting errors when trying to run Test::Unit tests. I\'m getting the error copied below. That comes from creating new,

相关标签:
12条回答
  • 2020-12-10 13:41

    As with aronchick's comment, for me (OS X 10.6) solution was

    sudo gem uninstall test-unit
    

    all versions.

    0 讨论(0)
  • 2020-12-10 13:44

    You get auto_test to work again with something like

    RUBY="ruby  -I.:lib:test -rubygems -e 'gem \"test-unit\"'" autotest
    
    0 讨论(0)
  • 2020-12-10 13:46

    Found the (ugly) solution:

    gem 'unit/test' must be called inside the tests too, not only in the Rakefile.

    0 讨论(0)
  • 2020-12-10 13:50

    This apparently comes from using Test::Unit 2.0 with the old Test::Unit. According to Kouhei Sutou on RubyForge, it can be fixed by calling gem 'test-unit' before you require 'test/unit'.

    0 讨论(0)
  • 2020-12-10 13:54

    If you add the following line to your environment.rb, or your config/environments/test.rb this should fix the issue

    config.gem "test-unit", :lib => "test/unit", :version => ">=2.0.9", :env => "test"
    

    I Believe you will need to add it before the mocha line if you use mocha.

    0 讨论(0)
  • 2020-12-10 13:55

    I was getting this without mocha or shoulda installed.

    This post suggests it's due to an incompatibility in test-unit >= 2.0, which I installed as a dependency for the systools gems. Downgrading to 1.2.3 worked for me, a simple require might also.

    0 讨论(0)
提交回复
热议问题