Created
March 30, 2010 03:15
-
-
Save bry4n/348717 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# Run Rspec-rails automatically with FSevent (like alloy's kicker, but using ruby-fsevent) | |
# Setup: | |
# 1) sudo cp autospec.rb /usr/local/bin/autospec | |
# 2) sudo chmod +x /usr/local/bin/autospec | |
# 3) cd /to/your/rails | |
# 4) autospec | |
begin | |
require 'fsevent' | |
rescue LoadError => boom | |
abort("Install ruby-fsevent with: sudo gem install ruby-fsevent") | |
end | |
class SpecsChange < FSEvent | |
def on_change(dir) | |
paths = dir.to_s.split("/") | |
name = paths[paths.size-1] | |
system("rake spec:#{name}") | |
end | |
def start | |
puts " ==> watching #{registered_directories.join(", ")}" | |
super | |
end | |
end | |
app = SpecsChange.new | |
app.latency = 0.2 | |
app.watch_directories %w(spec/controllers spec/models spec/helpers spec/views) | |
app.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment