After installation of Mocha (0.9.7), running “script/spec spec”
results in a “`const_missing’: uninitialized constant
Test::Unit::TestResult::TestResultFailureSupport (NameError)” error.
(As shown here; Ruby code - 15 lines - codepad )
I’m running Ruby 1.8.6 with Rails 2.3.4 on Windows, rspec (-rails)
1.2.8 (1.2.7.1), Test::Unit 2.0.3
As suggested roughly on
, I’ve added config.gem ‘test-unit’, :lib => ‘test/unit’" to my
environments/test.rb file at the very top. Doing so does resolve the
trace being printed, however, no output is generated at all when
running “script/spec spec” again. Removing the line brings back the
trace, but logically does not resolve the issue. ( Relevant Test::Unit
code is shown on Ruby code - 89 lines - codepad )
What other workarounds could I give a shot? Googling doesnt seem to
bring up alternative solutions sadly.
trace being printed, however, no output is generated at all when
running “script/spec spec” again. Removing the line brings back the
trace, but logically does not resolve the issue. ( Relevant Test::Unit
code is shown on http://codepad.org/bg7BlS7F )
What other workarounds could I give a shot? Googling doesnt seem to
bring up alternative solutions sadly.
I don’t know anything about the RSpec side of things, but the thing
that changed in Mocha >= 0.9.6 was that previously Mocha had itself
loaded Test::Unit whereas now it expects you to load Test::Unit
yourself before you then load Mocha.
How are you loading Mocha? If you are loading it with a config.gem
statement after the ‘test-unit’ one, then this should be ok and I
would guess the problem may lie in the integration with RSpec.
It seems that having the test-unit gem installed causes this problem.
On my Linux box, my rspec tests were all working fine for one project.
I started testing another project that I had imported from a Windows
development environment that referenced the test-unit gem.
Installing that gem on my Linux box gave me an error when trying to
run my rspec tests. After adding config.gem “test-unit” to test.rb,
the tests didn’t fail but didn’t run anymore. The newer application
also had the same issues.
I uninstalled the test-unit gem from my Linux machine and removed the
config.gem requirement from both the old and new applications and
everything ran fine again.
I also did this on my Windows machine and everything started running
as expected.
I uninstalled the test-unit gem from my Linux machine and removed the
config.gem requirement from both the old and new applications and
everything ran fine again.
I also did this on my Windows machine and everything started running
as expected.
I’m glad you’ve solved your problem.
However, it sounds like there might still be a problem with some
combination of Mocha, Test::Unit and RSpec (& RSpec on rails?).
It’d be great if you could create a ticket on Lighthouse [1] with
steps to reproduce the problem e.g. in a Rails app built from scratch.
Regards,
James M…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.