Created
July 19, 2012 12:35
-
-
Save joakimk/3143547 to your computer and use it in GitHub Desktop.
Command to run the specs the correct way when triggered from the turbux vim plugin.
This file contains hidden or 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
#!/usr/bin/env ruby | |
# | |
# Command to run the specs the correct way when triggered from the turbux vim plugin. | |
# | |
# - non-rails unit tests should be run without bundler env and have extra options. | |
# - rails tests should run with drb and retry if it exists right away (sometimes unreliable). | |
rails_spec = ARGV.first.start_with?("spec/") || ARGV.first.include?('/spec/') | |
if rails_spec | |
command = "rspec --drb" | |
else | |
# Don't load bundler for non-rails unit tests | |
command = "RUBYOPT='' rspec --color --tty" | |
end | |
command += " #{ARGV.first}" | |
loop do | |
t = Time.now | |
@success = system(command) | |
break unless rails_spec | |
# Retry when drb fails right away. It will take atleast a second | |
# if it succeeds, otherwise retry until it does. | |
break if Time.now - t > 1 | |
end | |
exit(1) unless @success |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment