I have a model which gets its data from a parser object. I\'m thinking that the parser class should live in the lib/ directory (although I could be persuaded that it should live
Here's one way:
Create lib/tasks/test_lib_dir.rake
with the following
namespace :test do
desc "Test lib source"
Rake::TestTask.new(:lib) do |t|
t.libs << "test"
t.pattern = 'test/lib/**/*_test.rb'
t.verbose = true
end
end
Mimic the structure of your lib
dir under the test
dir, replacing lib code with corresponding tests.
Run rake test:lib
to run your lib tests.
If you want all tests to run when you invoke rake test
, you could add the following to your new rake file.
lib_task = Rake::Task["test:lib"]
test_task = Rake::Task[:test]
test_task.enhance { lib_task.invoke }