Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Created January 16, 2012 15:52
Show Gist options
  • Select an option

  • Save seanbehan/1621483 to your computer and use it in GitHub Desktop.

Select an option

Save seanbehan/1621483 to your computer and use it in GitHub Desktop.
Sublime Text 2
## Tools > New Plugin...
{
"cmd": ["/path/to/script/run_rails_tests.rb", "$file"]
}
#!/usr/bin/env ruby
file = ARGV[0]
`cd #{ENV['PWD']}`
if file =~ /_test\.rb/
output = `cd #{ENV['PWD']} && ruby -Itest #{ARGV[0]}`
else
file = File.basename(file).gsub(/.rb/, '')
match = Dir["#{ENV['PWD']}/test/**/*.rb"].each do |f|
m = File.basename(f)
if m == "#{file}_test.rb"
output = `cd #{ENV['PWD']} && ruby -Itest #{f}`
end
end
end
puts output.gsub(/\[42;37;1m|\[0m|\[33;1;40mE|\[33;1;40m/, '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment