Test tasks missing from rake: rake aborted! Don't know how to build task 'test:units'
Asked Answered
I

1

6

I created a Rails 4 app recently and for some reason my rake tasks don't include test. Here's some console action to demonstrate the problem:

> rake test:units
    rake aborted!
    Don't know how to build task 'test:units'
    /Users/clozach/.rvm/gems/ruby-2.1.3@hoverfly/bin/ruby_executable_hooks:15:in `eval'
    /Users/clozach/.rvm/gems/ruby-2.1.3@hoverfly/bin/ruby_executable_hooks:15:in `<main>'
    (See full trace by running task with --trace)

Fail. :(

> rake test
>

No output. :(

> rake -T --all | grep test
    rake db:test:clone                      # 
    rake db:test:clone_schema               # 
    rake db:test:clone_structure            # 
    rake db:test:deprecated                 # 
    rake db:test:load                       # 
    rake db:test:load_schema                # 
    rake db:test:load_structure             # 
    rake db:test:prepare                    # 
    rake db:test:purge                      # 
    rake log:clear                          # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
    rake tmp/cache/assets/test              # 

No test tasks at all! :'(

Any idea why this is the case, and what I can do to fix it?

Isaisaac answered 11/11, 2014 at 20:14 Comment(0)
B
13

Take a look into config/application.rb whether the testing framework is actually required there. At the very top, there should be

require "rails/all"

Depending on your setup, you might have each individual component required separately. Make sure that test_unit is among them.

require "rails/test_unit/railtie" 
Buchmanism answered 15/11, 2014 at 20:17 Comment(1)
Yes, that was it. Obvious in retrospect, but so frustrating while unsolved! Thank you thank you thank you. :)Isaisaac

© 2022 - 2024 — McMap. All rights reserved.