Reputation: 46589
I have two apps. One is a very simple app that I built with rails new...
, added a unit test to and ran the unit test. The other is an existing app that is running fine but I'd like to add some tests to it. In AppA (the simple one) when I run rake -vT
I see:
...
rake test # Runs test:units, test:functionals, test:integrati...
rake test:recent # Run tests for {:recent=>"test:prepare"} / Test re...
rake test:single # Run tests for {:single=>"test:prepare"}
rake test:uncommitted # Run tests for {:uncommitted=>"test:prepare"} / Te...
...
Which seems normal. But when I run that same command in AppB (the existing app) I don't see any of the commands related to rake test
. My first thought was to just 'bring over' the tests from AppA to AppB to see if that would help. So I wiped all content from the test directory in AppB and copied over the test directory from AppA. Still no rake test
in the list of apps. But I can run a unit test in AppB via ruby -Itest test/unit/first_test.rb
(oddly I have to comment out fixtures :all
to get it to work, maybe that's a clue).
Upvotes: 0
Views: 431
Reputation: 46589
Found the answer to this last night. Where a new app's application.rb has:
require 'rails/all'
I had:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
I did that because I was following a guide about MongoMapper I think. Go forward a few versions and the last line is commented out -- that's the real reason. I commented it out at the same time I switched my ODM over to Mongoid. I'm not sure why I commented it out, but that definitely did it.
Upvotes: 1
Reputation: 5097
Without knowing the contents of your Rakefile
it's really hard to debug this, but you might be missing the .load_tasks
call in the Rakefile
.
If you're using Rails 3 you should have something like this:
MyApplication::Application.load_tasks
That line will take care of loading the default Rails tasks. You might be able to accomplish the same calling require "rails/tasks"
in your Rakefile
.
Upvotes: 0