-
Notifications
You must be signed in to change notification settings - Fork 9
Tapout on Rails
To begin, add Tapy to your Gemfile's test group:
group :test do
gem 'minitap'
gem 'tapout'
end
If you've previously installed other tools such as turn and minitest-reporters, remove them from your Gemfile and remove references to them in test/test_helper.rb.
Then run bundle.
RAILS_ENV=test bundle exec ruby test/models/user_test.rb --tapy | bundle exec tapout progress
Bit of a mouthful huh? You could alias that in ~/.bash_profile:
function tap {
# can use progress, outline, pretty, turn ...
RAILS_ENV=test bundle exec ruby $* --tapy | bundle exec tapout pretty
}
Then you can run, for example, tap test/models/user_test.rb or tap test/models/user_test.rb -n /login/.
Rails provides a set of Rake tasks for testing. While Rails::TestTask is a subclass on Rake::TestTask, it does not shell-out for testing like the Rake test task can, therefore adding a pipe to TESTOPTS will not work.
One work around for this, offered up by @abinoam, is to shell-out the Rails Rake task.
desc "Run 'rake test' through tapout"
task :tapout, [:reporter] do |t, args|
reporter = args.reporter || "runtime"
sh "RAILS_ENV='test' TESTOPTS='- --tapy' bin/rake -q test | tapout #{reporter}"
endWith this one can run rake tapout to run all tests. Or even rake tapout[outline] to select the output reporter.