module SpecWatchr::Specs
Public Instance Methods
default_rails_matcher(path, specs)
click to toggle source
# File lib/rspec-rails-watchr.rb, line 65 def default_rails_matcher path, specs specs.grep(/\b#{path}((_spec)?\.rb)?$/) end
match_specs(path, specs)
click to toggle source
# File lib/rspec-rails-watchr.rb, line 69 def match_specs path, specs matched_specs = @custom_matcher.call(path, specs) if @custom_matcher matched_specs = default_rails_matcher(path, specs) if matched_specs.nil? end
notify(message)
click to toggle source
# File lib/rspec-rails-watchr.rb, line 28 def notify message Thread.new do begin require 'notify' Notify.notify 'RSpec Result:', message rescue nil end end end
rspec(options)
click to toggle source
# File lib/rspec-rails-watchr.rb, line 43 def rspec options unless options.empty? success = run("bundle exec #{rspec_command} #{options}") notify( success ? '♥♥ SUCCESS :) ♥♥' : '♠♠ FAILED >:( ♠♠' ) end end
rspec_all()
click to toggle source
# File lib/rspec-rails-watchr.rb, line 50 def rspec_all rspec 'spec' end
rspec_command()
click to toggle source
# File lib/rspec-rails-watchr.rb, line 39 def rspec_command @rspec_command ||= File.exist?('./.rspec') ? 'rspec' : 'spec' end
rspec_files(*files)
click to toggle source
# File lib/rspec-rails-watchr.rb, line 54 def rspec_files *files rspec files.join(' ') end
specs_for(path)
click to toggle source
# File lib/rspec-rails-watchr.rb, line 58 def specs_for(path) print "--- Searching specs for #{path.inspect}...".yellow specs = match_specs path, Dir['spec/**/*_spec.rb'] puts specs.empty? ? ' nothing found.'.red : " #{specs.size} matched.".green specs end