module SpecWatchr::Specs

Public Instance Methods

check_if_bundle_needed() click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 172
def check_if_bundle_needed
  if `bundle exec #{rspec_command} -v` == `#{rspec_command} -v` 
    @bundle = ""
  else
    @bundle = "bundle exec "
  end
end
default_rails_matcher(path, specs) click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 203
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-emacs.rb, line 207
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?
  matched_specs
end
rspec(options) click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 180
def rspec options
  unless options.empty?
    results = run("#{@bundle}#{rspec_command} #{options}")
    # notify( success ? '♥♥ SUCCESS :) ♥♥' : '♠♠ FAILED >:( ♠♠' )
    rspec_send_results(results)
  end
end
rspec_all() click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 188
def rspec_all
  rspec 'spec'
end
rspec_command() click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 155
def rspec_command
  @rspec_command ||= File.exist?('./.rspec') ? 'rspec' : 'spec'
end
rspec_files(*files) click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 192
def rspec_files *files
  rspec files.join(' ')
end
rspec_send_results(results) click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 159
def rspec_send_results(results)
  begin
    print "--- Sending notification to #{@enotify_host}:#{@enotify_port}" \
    " through #{@enotify_slot_id}... ".cyan
    esend_results results 
    puts "Success!".green
  rescue
    puts "Failed!".red
    init_network
    rspec_send_results results 
  end
end
specs_for(path) click to toggle source
# File lib/rspec-rails-watchr-emacs.rb, line 196
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