Skip to content

Instantly share code, notes, and snippets.

@softcraft-development
Created August 1, 2011 23:30
Show Gist options
  • Save softcraft-development/1119245 to your computer and use it in GitHub Desktop.
Save softcraft-development/1119245 to your computer and use it in GitHub Desktop.
Craig's individual test runner
#!/usr/bin/env ruby
require "rubygems"
require 'activesupport'
file_name = ARGV[0].underscore.gsub(/_test$/, "")
test_name = ARGV[1].gsub(" ", "_") if ARGV[1]
paths = [
"test/unit/#{file_name}_test.rb",
"test/unit/helpers/#{file_name}_test.rb",
"test/functional/#{file_name}_controller_test.rb",
"test/functional/#{file_name}_test.rb",
"test/integration/#{file_name}_test.rb",
"test/profile/#{file_name}.rb"
]
executed = false
paths.each do |path|
if File.exist? path
command = "ruby -Ilib:test #{path} -n /#{test_name}/"
puts "Testing: #{test_name || 'All'} in #{path}"
puts command
puts `#{command}`
executed = true
break
end
end
puts "Could not find test file for #{file_name}" unless executed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment