-
-
Save danielres/4707807 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
ENV["WATCHR"] = "1" | |
system 'clear' | |
puts 'watching ...' | |
def notify(message) | |
title = "Watchr Test Results" | |
message.gsub!("No DRb server is running. Running in local process instead ...", "") | |
puts message | |
is_passing = message.match(/\s0\s(errors|failures)/) ? true : false | |
image = is_passing ? '~/.watchr/success.png' : '~/.watchr/failure.png' | |
# options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'" | |
title = is_passing ? 'All is well' : 'Timber !!' | |
message = message.split("\n").reject{|e|e==""}.first(1).join("\n") | |
system %(notify-send 'Tests:' '#{message}' -i #{image}) | |
# system "notify-send #{options} '#{message}'" | |
end | |
def run(cmd) | |
puts(cmd) | |
`#{cmd}` | |
end | |
def run_spec_file(file) | |
system('clear') | |
result = run(%Q(zeus rspec #{file})) | |
notify_result = result | |
notify notify_result rescue nil | |
puts result | |
end | |
def run_all_features | |
system('clear') | |
system("zeus cucumber") | |
end | |
def related_spec_files(path) | |
Dir['spec/**/*.rb'].select { |file| file =~ /#{File.basename(path).split(".").first}_spec.rb/ } | |
end | |
watch('spec/.*/.*_spec\.rb') { |m| run_spec_file(m[0]) } | |
watch('app/.*/.*\.rb') { |m| related_spec_files(m[0]).map {|tf| run_spec_file(tf) } } | |
watch('features/.*/.*\.feature') { run_all_features } | |
Signal.trap 'INT' do | |
abort("\n") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment