-
-
Notifications
You must be signed in to change notification settings - Fork 760
uninitialized constant Test::Unit::TestCase::Assertions (NameError) #482
Comments
Are you including the assertions like this? RSpec.configure do |config|
config.expect_with :stdlib
config.include ActiveSupport::Testing::Assertions
end |
I just included that in my spec_helper.rb - but getting the same error |
I had the same problem, and got it working by adding |
yep that sorted the issue, thanks. but still, it should be fixed from within rspec |
I encountered same issue. @helloworld's solution worked. |
You should not have to require |
@justinko, I think my spec_helper.rb is almost same as default. Here is the codes without comments. ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
end If I don't put require 'test/unit' I would get the error. |
@kinopyo - looking at what you pasted, you need to add this line:
That will load in the T/U assertions. |
@justinko--for T/U assertion usage with rspec-core, you're right. However, looking at the backtrace from @Znow, it appears to be an rspec-rails issue. The backtrace shows that rspec rails is requiring "test/unit/assertions" (here) and that is generating this error, even though he may not want to specifically use the test unit assertions (and hence, shouldn't have to configure |
@Znow--in the future, please try to report issues involving rspec-rails (especially when rspec-rails is in the backtrace) to the rspec-rails issue tracker. In that would have cut down on the miscommunication on this thread. @justinko assumed you were reporting an rspec-core issue since you reported it to rspec-core. |
This issue is really bizarre. If you look at the stack trace, all of the necessary files are being required. The error is basically saying that a module ( Obviously, if this was a "user wide" problem, blowing up every Rails app, it'd be fixed by now. I think the issue is specific to their environment. @Znow - can you paste your Gemfile? I'm stumped, and that's all I can think of. Hmm, maybe @dchelimsky has an idea. P.S. @myronmarston - your hyphens are blocking github from "tagging" the username. |
@myronmarston - okay... @justinko - https://github.com/Znow/advicecapital/blob/master/Gemfile <- this is a Gemfile for a larger project, but still the same issue. I had to manually require 'test/unit' in spec_helper |
@Znow, @justinko, I think I found the problem. It's gem 'turn'. I had 'minitest' in my Gemfile too, after I removed it and ran the rake spec, I got this error. Here is the stack trace.
You can see that error comes from turn. Seems like turn was requiring minitest. # under /Users/aa/.rvm/gems/ruby-1.9.2-p290/gems/turn-0.8.3/lib/turn/autorun/minitest.rb
require 'turn/autoload'
require 'minitest/unit'
require 'minitest/spec'
require 'turn/colorize'
require 'turn/controller'
require 'turn/runners/minirunner'
if MiniTest::Unit.respond_to?(:runner=)
MiniTest::Unit.runner = Turn::MiniRunner.new
else
raise "MiniTest v#{MiniTest::Unit::VERSION} is out of date.\n" \
"`gem install minitest` and add `gem 'minitest' to you test helper."
#MiniTest::Unit = Turn::MiniRunner
end So to sum up: |
@justinko - Yes, my :require => 'rspec' was necessary, or else it wouldnt recognize a certain command. and no, those 3 issues wont fix the issue, because I have already tried that, without any luck. |
Hi @justinko, I was having the same issue: C:\Sites\tasks>guard
←[0mUsing polling (Please help us to support your system better than that).←[0m
←[0mGuard is now watching at 'C:/Sites/tasks'←[0m
←[0mGuard::RSpec is running, with RSpec 2!←[0m
←[0m←[0mRunning all specs←[0m
You must use ANSICON 1.31 or later (http://adoxa.110mb.com/ansicon/) to use colo
ur on Windows
C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/test/unit/testcase.rb:9:in `<class:Te
stCase>': uninitialized constant Test::Unit::TestCase::Assertions (NameError)
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/test/unit/testcase.rb:8:
in `<module:Unit>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/test/unit/testcase.rb:4:
in `<module:Test>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/test/unit/testcase.rb:3:
in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/test/unit.rb:5:in `<top
(required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/test/unit/assertions.rb:
4:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-rails-2.
7.0/lib/rspec/rails/adapters.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-rails-2.
7.0/lib/rspec/rails.rb:10:in `<top (required)>'
from C:/Sites/tasks/spec/spec_helper.rb:4:in `<top (required)>'
from C:/Sites/tasks/spec/requests/tasks_spec.rb:1:in `require'
from C:/Sites/tasks/spec/requests/tasks_spec.rb:1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `load'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `map'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/configuration.rb:459:in `load_spec_files'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/command_line.rb:18:in `run'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/runner.rb:80:in `run_in_process'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/runner.rb:69:in `run'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7
.1/lib/rspec/core/runner.rb:10:in `block in autorun' and my Gemfile looked like: source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test, :development do
gem 'turn'
gem 'minitest', '~> 2.6.1'
gem 'rspec-rails'
gem 'capybara'
gem 'guard-rspec'
gem 'rb-notifu'
end I removed gem 'turn' from my Gemfile and it solved the issue. C:\Sites\tasks>guard
←[0mUsing polling (Please help us to support your system better than that).←[0m
←[0mGuard is now watching at 'C:/Sites/tasks'←[0m
←[0mGuard::RSpec is running, with RSpec 2!←[0m
←[0m←[0mRunning all specs←[0m
You must use ANSICON 1.31 or later (http://adoxa.110mb.com/ansicon/) to use colo
ur on Windows
F
Failures:
1) Tasks GET /tasks works! (now write some real specs)
Failure/Error: get tasks_index_path
NameError:
undefined local variable or method `tasks_index_path' for #<RSpec::Core::
ExampleGroup::Nested_1::Nested_1:0x28c6260>
# ./spec/requests/tasks_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 26.64 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/tasks_spec.rb:5 # Tasks GET /tasks works! (now write some
real specs) Awesome, thanks! I just installed ruby so I pretty much have a default installation. I had thought getting an error like this was a bit odd. Btw, quick question if you don't mind. Where it says "←[0mUsing polling (Please help us to support your system better than that).←[0m", what does that actually mean? I assumed it was because I was using cmd instead of another tool, but I've tried google-ing it and I'm wasn't really able to find anything helpful. |
It's a message from guard. It means it has to use polling to detect file changes, as opposed to an event-based system. See the guard readme for more info. |
+1 to removing gem "turn" to solve this issue |
-1 to removing |
I would agree that it should be fine to have both T::U tests and rspec specs in the same project, and to use turn with the T::U tests. As far as I know, having this setup doesn't cause problems....it's once you load
I agree. I've never used turn and don't have the time to play with it, but if anyone can determine if turn is at fault in any way, I would encourage you to submit an issue to the turn tracker.
I'm not convinced RSpec should work around a gem that's only designed to work with an entirely different test framework when the simple solution is to simply not load it in your rspec environment. |
Submitted as turn-project/turn#117. |
Has anyone tried putting |
It's still unclear to me why anyone is loading turn in your rspec environment. As I asked above, why can't you just only load it in your Test::Unit environment? |
Presumably you mean |
That, or not using |
Ah, so maybe the problem is that |
Hi there.
I get this error, EVERY time I try run guard or bundle exec rspec or similar..
ive tried googling the error for the past couple of hours and days.
the full error msg:
thanks in advance
The text was updated successfully, but these errors were encountered: