Created
May 10, 2014 05:09
-
-
Save kizzx2/29b703488367ee852af2 to your computer and use it in GitHub Desktop.
Run single test with Spring in Rails 4.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'optparse' | |
$: << Rails.root.join('test') | |
options = {} | |
OptionParser.new do |opts| | |
opts.on('-n TEST_NAME') do |n| | |
options[:test_name] = n | |
end | |
opts.on('-e ENVIRONMENT') do |e| | |
raise ArgumentError.new("Must run in test environment") if e != 'test' | |
end | |
end.parse! | |
test_files = ARGV.dup | |
ARGV.clear | |
if options[:test_name] | |
ARGV << "-n" << options[:test_name] | |
end | |
test_files.each do |f| | |
Dir[f].each do |f1| | |
load f1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage is almost like the good old
ruby -I test
way: