Skip to content

Instantly share code, notes, and snippets.

@pdswan
Created March 22, 2011 01:18
Show Gist options
  • Save pdswan/880582 to your computer and use it in GitHub Desktop.
Save pdswan/880582 to your computer and use it in GitHub Desktop.
Basic Watchr Rules and Actions
def run_spec(file)
unless File.exist?(file)
puts "#{file} does not exist"
return
end
puts "Running #{file}"
system "bundle exec rspec #{file}"
puts
end
def run_migrations
system "rake db:migrate"
system "rake db:test:prepare"
end
watch("db/migrate/.*\.rb") do |match|
run_migrations
end
watch("spec/.*/*_spec\.rb") do |match|
run_spec match[0]
end
watch("app/(.*/.*)\.rb") do |match|
run_spec %{spec/#{match[1]}_spec.rb}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment