Reputation: 183
Hello all and thanks in advance for the feedback.
I have a new rails 5.0.4 project (ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin15]) and am having an issue when running my first minitest pass.
The command:
bin/rails test
The error
TypeError: ActiveSupport is not a class
<sanatized>/ps/tekkedout-dnd-tools/test/test_helper.rb:5:in `<top (required)>'
<sanatized>/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.4/lib/active_support/dependencies.rb:293:in `require'
<sanatized>/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.4/lib/active_support/dependencies.rb:293:in `block in require'
<sanatized>/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.4/lib/active_support/dependencies.rb:259:in `load_dependency'
<sanatized>/.rvm/gems/ruby-2.3.4/gems/activesupport-5.0.4/lib/active_support/dependencies.rb:293:in `require'
<sanatized>/ps/tekkedout-dnd-tools/test/models/spell_test.rb:1:in `<top (required)>'
test_helper.rb
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
class ActiveSupport
class TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
end
Looks like when implementing rubocop I made some hasty changes and hadn't started with my specs yet.
Here is the diff:
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
- fixtures :all
+class ActiveSupport
+ class TestCase
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
- # Add more helper methods to be used by all tests here...
+ # Add more helper methods to be used by all tests here...
+ end
Upvotes: 2
Views: 1669
Reputation: 5967
ActiveSupport
is not a class but a module:
ActiveSupport.class
#=> Module
To patch the ActiveSupport::TestCase
class, try this:
module ActiveSupport
class TestCase
# ...
end
end
Upvotes: 3
Reputation: 2436
I think what you want is:
class ActiveSupport::TestCase
[...]
end
ActiveSupport
is a module, not a class. It's being used as a namespace here for the TestCase
class. Here's the relevant bit of code in active_support
5.0.2: https://github.com/rails/rails/blob/v5.0.2/activesupport/lib/active_support/test_case.rb#L14
Upvotes: 0