Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant Test when running Rails console

I'm getting uninitialized constant Test when running rails console in terminal. I'm not sure why I just set it up and using the command rails server works.

This is the error I get:

/usr/lib/ruby/vendor_ruby/active_support/test_case.rb:12:in `<module:ActiveSupport>': uninitialized constant Test (NameError)
like image 776
David Q Avatar asked Jun 03 '14 17:06

David Q


2 Answers

I ran into this same problem on my Ubuntu 14.04 desktop. Solved in the following way:

sudo apt-get install ruby-test-unit echo require 'test/unit' >> /usr/lib/ruby/vendor_ruby/active_support/test_case.rb

see this link: https://bugs.launchpad.net/ubuntu/+source/ruby-activesupport-3.2/+bug/1319101

like image 53
dezhi Avatar answered Nov 15 '22 14:11

dezhi


I had this issue when copied and pasted the config from shoulda-matchers getting started guide. But I wasn't removing the unused tests frameworks.

To use with RSpec it will be as:

Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    # Choose a test framework:
    with.test_framework :rspec
    # with.test_framework :minitest
    # with.test_framework :minitest_4
    # with.test_framework :test_unit

    # Choose one or more libraries:
    with.library :active_record
    with.library :active_model
    with.library :action_controller
    # Or, choose the following (which implies all of the above):
    with.library :rails
  end
end
like image 36
Bruno Peres Avatar answered Nov 15 '22 14:11

Bruno Peres