Add Functional Test to test:functionals Task

I have what I think should be a simple problem, but I’m having issues
finding a solution to it via Google.

I’m writing functional tests for my AccountsController. I began by
adding
tests to the test/functionals/accounts_controller_test.rb file, which
worked fine. However, my testing has become significant enough that that
file has gotten incredibly long. I would like to split my tests into
individual files, like accounts_controller_test_index.rb,
accounts_controller_test_show.rb, etc. I can do that, but it was a bit
hacky-- the accounts_controller_test_show.rb had to look like this:

require ‘functional/accounts_controller_test’

class AccountsControllerTestShow < AccountsControllerTest

end

but even that was okay. The real problem is that the only way I can run
this file is explicitly:

rake test TEST=test/functionals/accounts_controller_test_show.rb

It simply won’t run when rake test:functionals is called.

So, I have two questions:

  1. Is the way I’ve split this out (i.e. the require
    accounts_controller_test and inheritance) the right way to do this?
  2. How do I add this test to be run when rake test:functionals is run? I
    thought that rake task ran all the test/functionals/*.rb files, but
    apparently I was wrong.

Thank you!

Kyle

Ah… it WAS a simple problem. I know I’ve seen this multiple times, but
I never had to use this knowledge until now: the rake tasks don’t
recursively run *.rb files, they recursively run *_test.rb files. I just
had to name my files better.

My first question still stands, though. If I don’t do the
include/inheritance, I get complaints about the AccountsController not
existing.

Kyle

On Saturday, August 17, 2013 7:49:49 PM UTC+1, Kyle Fazzari wrote:

Ah… it WAS a simple problem. I know I’ve seen this multiple times, but I never
had to use this knowledge until now: the rake tasks don’t recursively run *.rb
files, they recursively run *_test.rb files. I just had to name my files better.

My first question still stands, though. If I don’t do the include/inheritance, I
get complaints about the AccountsController not existing.

You can keep inheriting from ActionController::TestCase, you just need
to tell rails which controller class is being tested (by default rails
gets this from the test class name):

class MoreTests < ActionController::TestCase
tests AccountsController

end

Fred