Sha256: 3715e1f71a593ccfe9a54b814a0a680dfc3944924c2bc4ff756c3f317795dc80

Contents?: true

Size: 1.41 KB

Versions: 59

Compression:

Stored size: 1.41 KB

Contents

# Run me with:
#
#   $ watchr specs.watchr

# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def all_test_files
  Dir['spec/**/*_spec.rb']
end

def run_test_matching(thing_to_match)
  matches = all_test_files.grep(/#{thing_to_match}/i)
  if matches.empty?
    puts "Sorry, thanks for playing, but there were no matches for #{thing_to_match}"  
  else
    run matches.join(' ')
  end
end

def run(files_to_run)
  puts("Running: #{files_to_run}")
  system("clear;rspec -cfs #{files_to_run}")
  no_int_for_you
end

def run_all_tests
  run(all_test_files.join(' '))
end

# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch('^spec/(.*)_spec\.rb'  )   { |m| run_test_matching(m[1]) }
watch('^lib/(.*)\.rb'               )   { |m| run_test_matching(m[1]) }
watch('^spec/spec_helper\.rb')   { run_all_tests }
# --------------------------------------------------
# Signal Handling
# --------------------------------------------------

def no_int_for_you
  @sent_an_int = nil
end

Signal.trap 'INT' do
  if @sent_an_int then      
    puts "   A second INT?  Ok, I get the message.  Shutting down now."
    exit
  else
    puts "   Did you just send me an INT? Ugh.  I'll quit for real if you do it again."
    @sent_an_int = true
    Kernel.sleep 1.5
    run_all_tests
  end
end

# vim:ft=ruby

Version data entries

59 entries across 59 versions & 5 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-expectations-2.5.0/specs.watchr
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-expectations-2.5.0/specs.watchr
rspec-expectations-2.6.0 specs.watchr
rspec-expectations-2.6.0.rc6 specs.watchr
rspec-expectations-2.6.0.rc4 specs.watchr
rspec-expectations-2.6.0.rc2 specs.watchr
rspec-expectations-2.5.0 specs.watchr
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/specs.watchr
rspec-expectations-2.4.0 specs.watchr
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/specs.watchr
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/specs.watchr
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/specs.watchr
rspec-expectations-2.3.0 specs.watchr
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/specs.watchr
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/specs.watchr
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/specs.watchr
rspec-expectations-2.2.0 specs.watchr
rspec-expectations-2.1.0 specs.watchr
rspec-expectations-2.0.1 specs.watchr
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/specs.watchr