Uninitialized constant Test :: Unit :: TestResult :: TestResultFailureSupport

I am getting an error in subj when I try to run specs or generators in a new rails project.

This happens when I add toa to the mix.

I added the following to config / environment.rb:

config.gem 'rspec', :version => '1.2.6', :lib => false
config.gem 'rspec-rails', :version => '1.2.6', :lib => false
config.gem "thoughtbot-shoulda", :version => "2.10.2", :lib => 'shoulda', :source => "http://gems.github.com"

      

I'm on OSX.

  • ruby 1.8.6 (2008-08-11 patchlevel 287)
  • gems 1.3.5
  • rails 2.3.4
  • rspec - 1.2.6
  • shoulda - 2.10.2
  • test-unit - 2.0.3

I know this and adding config.gem 'test-unit', :lib => 'test/unit'

really solves the genrator problem as it does not throw an exception but prints 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications

to the end of the run, so I guess it is trying to run tests that are unexpected and unwanted, all functions also stop running, it looks like rspec does not at all works, on run rake spec

I get testblock output again (with 0 tests as there are only specs, no tests defined)

+2


source to share


3 answers


I recently ran into a similar issue and traced it with this commit in rubygems:

http://github.com/vvs/rubygems/commit/cbb4b07d491dd49b8dff8ab7af706dde31307c7d



Which loads the 'test-unit' gem if there is one, or moves silently if it doesn't. The author of this change may not be aware of a fundamental truth - that activating a gem can often change the behavior of other gemstones loaded into the system. Application developers should be responsible for defining the set of gems they want to activate; what the rubygems system itself decides to optionally load the gem is the head-cleaner.

The other half of this problem is the question of why the test-unit gem interferes with the rspec. This I cannot answer, but I traced it back to no exampleGroup registered, which in turn is due to the fact that the "inherited" callback in ExampleGroupMethods is not called when Rspec dynamically creates a new ActiveSupport :: TestCase subclass (this happens in a subclass of ExampleGroupMethods #)

+1


source


Based on the conversation I found here , it looks like the problem is not that RSpec dies with all versions of the test block, it is incompatible with newer ones. So removing the test block altogether is one workaround. But if that isn't an option for you (as it isn't for me), you can install an older version (like 1.2.3) and just make sure it's loaded before rspec.

For example, I have this in my environment / test.rb file and the tests run again:



config.gem 'test-unit'  , :lib => 'test/unit',  :version => '<2.0'
config.gem "rspec",       :lib => false, :version => '<2.0'
config.gem "rspec-rails", :lib => false, :version => '<2.0'

      

+1


source


test-unit is actually inline in Ruby, so removing the gem falls to inline Ruby. Unless you need something special that is not included in the default test unit, I wouldn't worry too much about that.

0


source







All Articles