Sha256: 9671e5335290402145be0c489624a7ddf07bad42c63da741db1d0599f759148a

Contents?: true

Size: 1.44 KB

Versions: 30

Compression:

Stored size: 1.44 KB

Contents

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

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

def run_spec_matching(thing_to_match)
  matches = all_spec_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_specs
  run(all_spec_files.join(' '))
end

# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch('^spec/(.*)_spec\.rb')   { |m| run_spec_matching(m[1]) }
watch('^lib/(.*)\.rb')         { |m| run_spec_matching(m[1]) }
watch('^spec/spec_helper\.rb') { run_all_specs }
watch('^spec/support/.*\.rb')   { run_all_specs }

# --------------------------------------------------
# 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_specs
  end
end

# vim:ft=ruby

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
audited_change_set-0.0.6 specs.watchr
audited_change_set-0.0.5 specs.watchr
rspec-rails-2.5.0 specs.watchr
rspec-rails-2.4.1 specs.watchr
rspec-rails-2.4.0 specs.watchr
rspec-rails-2.3.1 specs.watchr
rspec-rails-2.3.0 specs.watchr
rspec-rails-2.2.1 specs.watchr
rspec-rails-2.2.0 specs.watchr
rspec-rails-2.1.0 specs.watchr
rspec-rails-2.0.1 specs.watchr
rspec-rails-2.0.0 specs.watchr
rspec-rails-2.0.0.rc specs.watchr
rspec-rails-2.0.0.beta.22 specs.watchr
rspec-rails-2.0.0.beta.20 specs.watchr
rspec-rails-2.0.0.beta.19 specs.watchr
rspec-rails-2.0.0.beta.18 specs.watchr
rspec-rails-2.0.0.beta.17 specs.watchr
rspec-rails-2.0.0.beta.16 specs.watchr
rspec-rails-2.0.0.beta.15 specs.watchr