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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/04d138c8-91e4-4fe0-8d87-13af6f697d13%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
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 08/17/2013 10:54 AM, Kyle Fazzari wrote:> 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 > -- > You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/-7PgmiuguRE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/04d138c8-91e4-4fe0-8d87-13af6f697d13%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/520FC5CD.2020409%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
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> > > Kyle > > > > On 08/17/2013 10:54 AM, Kyle Fazzari wrote: > > > 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 > > > -- > > > You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group. > > > To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/-7PgmiuguRE/unsubscribe. > > > To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/04d138c8-91e4-4fe0-8d87-13af6f697d13%40googlegroups.com. > > > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9a2fa13d-1b77-40ec-8d74-ddbf779fa5e0%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.