Class | Autotest::Rspec
In: | lib/autotest/rspec.rb
Parent: | Autotest

### Methods

add_options_if_present consolidate_failures handle_results make_test_cmd tests_for_file

### Public Instance methods

add_options_if_present()

[Source]

        # File lib/autotest/rspec.rb, line 64
    64:   def add_options_if_present
    65:     File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
    66:   end

consolidate_failures(failed)

[Source]

        # File lib/autotest/rspec.rb, line 33
    33:   def consolidate_failures(failed)
    34:     filters = Hash.new { |h,k| h[k] = [] }
    35:     failed.each do |spec, failed_trace|
    36:       @files.keys.select{|f| f =~ /spec\//}.each do |f|
    37:         if failed_trace =~ Regexp.new(f)
    38:           filters[f] << spec
    39:           break
    40:         end
    41:       end
    42:     end
    43:     return filters
    44:   end

handle_results(results)

[Source]

        # File lib/autotest/rspec.rb, line 22
    22:   def handle_results(results)
    23:     failed = results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
    24:     @files_to_test = consolidate_failures failed
    25:     unless @files_to_test.empty? then
    26:       hook :red
    27:     else
    28:       hook :green
    29:     end unless $TESTING
    30:     @tainted = true unless @files_to_test.empty?
    31:   end

make_test_cmd(files_to_test)

[Source]

        # File lib/autotest/rspec.rb, line 46
    46:   def make_test_cmd(files_to_test)
    47:     cmds = []
    48:     full, partial = files_to_test.partition { |k,v| v.empty? }
    49:
    50:     unless full.empty? then
    51:       files = full.map {|k,v| k}.flatten.join(' ')
    52:       cmds << "#{@spec_command} #{add_options_if_present}#{files}"
    53:     end
    54:
    55:     partial.each do |f, methods|
    56:       cmds.push(*methods.map { |meth|
    57:         "#{@spec_command} #{add_options_if_present} #{f}"
    58:       })
    59:     end
    60:
    61:     return cmds.join('; ')
    62:   end

tests_for_file(filename)

[Source]

        # File lib/autotest/rspec.rb, line 18
    18:   def tests_for_file(filename)
    19:     super.select { |f| @files.has_key? f }
    20:   end

[Validate]