Class: SpecWatchr

Inherits:
Object show all
Includes:
CommandLine, Control, Specs
Defined in:
lib/rspec-rails-watchr.rb

Defined Under Namespace

Modules: CommandLine, Control, Specs

Instance Method Summary collapse

Methods included from Control

#abort_watchr!, #exit_watchr, #reload!, #reload_file_list, #trap_int!

Methods included from Specs

#default_rails_matcher, #match_specs, #notify, #rspec, #rspec_all, #rspec_command, #rspec_files, #specs_for

Methods included from CommandLine

#clear!, #run, #terminal_columns

Constructor Details

#initialize(watchr, &block) ⇒ SpecWatchr

Returns a new instance of SpecWatchr.



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/rspec-rails-watchr.rb', line 130

def initialize watchr, &block
  @custom_matcher = block if block_given?
  @watchr = watchr

  watchr.watch('^spec/(.*)_spec\.rb$')                     {|m| rspec_files specs_for(m[1])}
  watchr.watch('^(?:app|lib|script)/(.*)(?:\.rb|\.\w+|)$') {|m| rspec_files specs_for(m[1].gsub(/\.rb$/,''))}

  trap_int!

  puts '--- Waiting for changes...'.cyan
end