Created
December 12, 2012 11:01
-
-
Save ssaunier/4266952 to your computer and use it in GitHub Desktop.
Lightweight alternative to guard. Run rspec over spork as you code watching changes to your code base.
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
def run_spec(file) | |
unless File.exist?(file) | |
puts "#{file} does not exist, no specs to run." | |
return | |
end | |
puts "Running #{file}" | |
system "bundle exec rspec #{file} --drb --colour" | |
puts | |
end | |
# Obviously rerun tests when spec file is updated | |
watch("spec/.*/*_spec.rb") do |match| | |
run_spec match[0] | |
end | |
# Run specs for app/ folder | |
watch("app/(.*/.*).rb") do |match| | |
run_spec %{spec/#{match[1]}_spec.rb} | |
end | |
# Run specs for lib/ folder | |
watch("^lib/(.*/.*).rb") do |match| | |
run_spec %{spec/lib/#{match[1]}_spec.rb} | |
end |
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
group :development, :test do | |
gem "watchr" | |
gem "rb-fsevent" # If you are not on MacOSX: https://github.com/guard/guard#efficient-filesystem-handling | |
gem "spork" | |
end |
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
desc "Run watchr" | |
task :watchr do | |
fork do | |
sh %{bundle exec spork} | |
end | |
sh %{bundle exec watchr .watchr} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment