Class | Autotest::Rspec |
In: |
lib/autotest/rspec.rb
|
Parent: | Autotest |
# File lib/autotest/rspec.rb, line 65 65: def add_options_if_present 66: File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : "" 67: end
# File lib/autotest/rspec.rb, line 48 48: def consolidate_failures(failed) 49: filters = Hash.new { |h,k| h[k] = [] } 50: failed.each do |spec, failed_trace| 51: @files.keys.select{|f| f =~ /spec\//}.each do |f| 52: if failed_trace =~ Regexp.new(f) 53: filters[f] << spec 54: break 55: end 56: end 57: end 58: return filters 59: end
# File lib/autotest/rspec.rb, line 34 34: def failed_results(results) 35: results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m) 36: end
# File lib/autotest/rspec.rb, line 38 38: def handle_results(results) 39: @files_to_test = consolidate_failures failed_results(results) 40: unless @files_to_test.empty? then 41: hook :red 42: else 43: hook :green 44: end unless $TESTING 45: @tainted = true unless @files_to_test.empty? 46: end
# File lib/autotest/rspec.rb, line 61 61: def make_test_cmd(files_to_test) 62: return "#{ruby} -S #{@spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}" 63: end
Finds the proper spec command to use. Precendence is set in the lazily-evaluated method spec_commands. Alias + Override that in ~/.autotest to provide a different spec command then the default paths provided.
# File lib/autotest/rspec.rb, line 73 73: def spec_command 74: spec_commands.each do |command| 75: if File.exists?(command) 76: return @alt_separator ? (command.gsub @separator, @alt_separator) : command 77: end 78: end 79: raise RspecCommandError, "No spec command could be found!" 80: end
Autotest will look for spec commands in the following locations, in this order:
* bin/spec * default spec bin/loader installed in Rubygems
# File lib/autotest/rspec.rb, line 87 87: def spec_commands 88: [ 89: File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')), 90: File.join(Config::CONFIG['bindir'], 'spec') 91: ] 92: end