Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails console and rake test:units

I was wondering whether I could run my tests under rails console rather than the command line. Actually the rationale for this is that rake test:units on the command line takes ages to load the rails environment. So I thought, why not start a console to load the environment once and then keep running rake unit:tests each time I wanted to check my code. After all, rails is meant to be agile and promote agile development. So I tried this. First of all I had to say:

require 'Rake'

but even after doing that I got the error message:

irb(main):002:0> Rake::Task['test.units'].invoke
RuntimeError: Don't know how to build task 'test.units'

I guess I need to somehow tell it where to look. Any thoughts?

Thanks

Chris

like image 571
Chris Avatar asked Aug 21 '11 13:08

Chris


1 Answers

ruby-1.9.2-p290 :001 > require 'rake'
ruby-1.9.2-p290 :002 > r = Rake.application
ruby-1.9.2-p290 :003 > r.init
ruby-1.9.2-p290 :004 > r.load_rakefile
ruby-1.9.2-p290 :005 > r['test:units'].invoke
like image 90
Vasiliy Ermolovich Avatar answered Sep 25 '22 04:09

Vasiliy Ermolovich