-
Notifications
You must be signed in to change notification settings - Fork 9
Tapout on Rails
Michael Mahemoff edited this page Mar 25, 2015
·
5 revisions
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 {
RAILS_ENV=test bundle exec ruby $1 --tapy | bundle exec tapout progress
}
Then just run tap test/models/user_test.rb
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}"
end
With this one can run rake tapout
to run all tests. Or even rake tapout[outline]
to select the output reporter.