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

### Methods

add_options_if_present consolidate_failures make_test_cmd new spec_command spec_commands

### Public Class methods

new()

[Source]

        # File lib/autotest/rspec.rb, line 22
    22:   def initialize
    23:     super
    24:
    25:     self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
    26:     self.completed_re = /\Z/ # FIX: some sort of summary line at the end?
    27:   end

### Public Instance methods

add_options_if_present()

[Source]

        # File lib/autotest/rspec.rb, line 44
    44:   def add_options_if_present
    45:     File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
    46:   end

consolidate_failures(failed)

[Source]

        # File lib/autotest/rspec.rb, line 29
    29:   def consolidate_failures(failed)
    30:     filters = Hash.new { |h,k| h[k] = [] }
    31:     failed.each do |spec, failed_trace|
    32:       if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then
    33:         filters[f] << spec
    34:         break
    35:       end
    36:     end
    37:     return filters
    38:   end

make_test_cmd(files_to_test)

[Source]

        # File lib/autotest/rspec.rb, line 40
    40:   def make_test_cmd(files_to_test)
    41:     return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
    42:   end

spec_command(separator=File::ALT_SEPARATOR)

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.

[Source]

        # File lib/autotest/rspec.rb, line 52
    52:   def spec_command(separator=File::ALT_SEPARATOR)
    53:     unless defined? @spec_command then
    54:       @spec_command = spec_commands.find { |cmd| File.exists? cmd }
    55:
    56:       raise RspecCommandError, "No spec command could be found!" unless @spec_command
    57:
    58:       @spec_command.gsub! File::SEPARATOR, separator if separator
    59:     end
    60:     @spec_command
    61:   end

spec_commands()

Autotest will look for spec commands in the following locations, in this order:

      * bin/spec
      * default spec bin/loader installed in Rubygems

[Source]

        # File lib/autotest/rspec.rb, line 68
    68:   def spec_commands
    69:     [
    70:       File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')),
    71:       File.join(Config::CONFIG['bindir'], 'spec')
    72:     ]
    73:   end

[Validate]