Created
April 29, 2011 02:18
-
-
Save koko-u/947723 to your computer and use it in GitHub Desktop.
ファイルの更新に伴いspecを実行するwatchr
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" | |
return | |
end | |
puts "Running #{file}" | |
system "bundle exec rspec #{file}" | |
puts | |
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 | |
watch("app/(.*/.*\.erb)") do |match| | |
run_spec %{spec/#{match[1]}_spec.rb} | |
end | |
watch("config/routes.rb") do |match| | |
Dir["spec/routing/*_spec.rb"].each do |spec_file| | |
run_spec spec_file | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment