Reputation: 43153
The question title pretty much sums it up, but here's a more chronological description:
minitest-rails
to the gemfile and ran bundle install.rails g mini_test:install
.Now if I run rake test
, nothing happens.
I can make my own rakefile and specify TestTask
manually, but I don't get the options to do things like rake test:controllers
that are supposed to come built-in unless I manually dupe all that.
Has anyone else run into this?
Upvotes: 4
Views: 1815
Reputation: 1749
Make sure you add require 'test_helper'
on top of your test file. e.g.
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
test "should pass" do
assert true
end
end
The auto generated test_helper file I have looks like that:
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
fixtures :all
end
Upvotes: 2
Reputation: 1869
Glad you are making the switch to MiniTest! I may be able to help you get on the right track.
Honestly, I would avoid rake entirely. Try running a test from the command line to make sure your testing suite is working.
ruby -Itest test/unit/something.rb
After you know your tests are passing then get guard-minitest and set it up to watch your files. When you save a change it will automatically run the test for you. The worst part of minitest and guard is the set up but once you get it going right you'll never want to go back.
https://github.com/guard/guard-minitest
Cheers
Upvotes: 1
Reputation: 8984
You may need to register minitest-rails as the default testing engine by adding the following to your config/application.rb
file:
config.generators do |g|
g.test_framework :mini_test
end
After that, you can run controller tests with the following:
rake minitest:controllers
Upvotes: 0
Reputation: 1177
I guess you had not run/generate any controller or scaffold command so far. Once you create a scaffold / controller / model and migrate the database your rake test will start working
Regarding rake test:controllers, when I tried to list out with rake -T it is not still listing
Upvotes: 0