Skip to content

Instantly share code, notes, and snippets.

@brokensandals
Created September 5, 2010 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brokensandals/566077 to your computer and use it in GitHub Desktop.
Save brokensandals/566077 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
TASK_NAMES = {'unit' => 'units',
'functional' => 'functionals',
'integration' => 'integration'}
tasks = {'unit' => [],
'functional' => [],
'integration' => []}
requested = ARGV.clone
requested.each do |a|
found = false
tasks.each do |dir,tests|
test, method = a.split '.', 2
Dir.glob "test/#{dir}/#{test}{_controller,}_test.rb" do |path|
found = true
tests << {:file => path}
tests[-1][:method] = "/#{method}/" if method
end
end
requested.push "**/#{a}" unless found || a[0..2] == "**/"
end
tasks.each do |dir,tests|
tests.uniq.each do |test|
header = "#{test[:file].gsub /(test\/.*?\/|\.rb)/, ''}"
header += ": #{test[:method]}" if test[:method]
puts "\e[45m \e[m \e[35m#{header}\e[m"
opts = test[:method] ? " TESTOPTS=\"--name=#{test[:method]}\"" : ""
system "rake test:#{TASK_NAMES[dir]} TEST=\"#{test[:file]}\"#{opts}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment