Sha256: efc15e67608f70f8a793329f31ff922c30185c2c691e73a88c16ada1c2151393

Contents?: true

Size: 1.16 KB

Versions: 54

Compression:

Stored size: 1.16 KB

Contents

# vim:set filetype=ruby:
def growl
  title = "Watchr Test Results"
  image = $?.success? ? "~/.watchr/images/passed.png" : "~/.watchr/images/failed.png"
  message = $?.success? ? "success" : "failed"
  growlnotify = `which growlnotify`.chomp
  options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
  system %(#{growlnotify} #{options} &)
end

def run(cmd)
  puts cmd
  system(cmd)
end

def spec(file)
  if File.exists?(file)
    run("rspec #{file}")
    growl
  else
    puts("Spec: #{file} does not exist.")
  end
end


def run_all_specs
  run "rake spec"
  growl
end

def run_suite
  system "clear"
  run_all_specs
end

watch("spec/.*/*_spec\.rb") do |match|
  puts(match[0])
  spec(match[0])
end

watch("lib/(.*/.*)\.rb") do |match|
  puts(match[1])
  spec("spec/#{match[1]}_spec.rb")
end


# Ctrl-\
Signal.trap 'QUIT' do
  puts " --- Running all tests ---\n\n"
  run_suite
 end

# Ctrl-C
Signal.trap 'INT' do
  if @interrupted then
    abort("\n")
  else
    puts "Interrupt a second time to quit"
    @interrupted = true
    Kernel.sleep 1.5
    # raise Interrupt, nil # let the run loop catch it
    run_suite
    @interrupted = false
  end
end

Version data entries

54 entries across 32 versions & 2 rubygems

Version Path
rails_best_practices-1.9.0 .watchr.example
rails_best_practices-1.8.0 .watchr.example
rails_best_practices-1.7.2 .watchr.example
rails_best_practices-1.7.1 .watchr.example
rails_best_practices-1.7.0 .watchr.example
rails_best_practices-1.6.0 .watchr.example
rails_best_practices-1.5.3 .watchr.example
rails_best_practices-1.5.2 .watchr.example
rails_best_practices-1.5.1 .watchr.example
rails_best_practices-1.5.0 .watchr.example
rails_best_practices-1.4.0 .watchr.example
rails_best_practices-1.4.0 .watchr
rails_best_practices-1.3.0 .watchr
rails_best_practices-1.3.0 .watchr.example
rails_best_practices-1.2.0 .watchr
rails_best_practices-1.2.0 .watchr.example
rails_best_practices-1.1.0 .watchr.example
rails_best_practices-1.1.0 .watchr
rails_best_practices-1.0.1 .watchr.example
rails_best_practices-1.0.1 .watchr