#!/usr/bin/env ruby if $0 == __FILE__ puts "Watchr started!" system("watchr #{__FILE__}") else # -------------------------------------------------- # Convenience Methods # -------------------------------------------------- def run(files_to_run) command = "bundle exec rspec #{files_to_run}" puts "Running: #{command}" system command end def run_spec_matching(matchdata) run "spec/#{matchdata[1]}_spec.rb" end def run_all_specs run 'spec' end # -------------------------------------------------- # Watchr Rules # -------------------------------------------------- watch '^lib/(.*)\.rb' do |matchdata| run_spec_matching(matchdata) end watch '^spec/(.*)_spec\.rb' do |matchdata| run_spec_matching(matchdata) end watch '^spec/spec_helper\.rb' do run_all_specs end watch '^spec/support/.*\.rb' do run_all_specs end end