Sha256: e458771424a0bdeeaa7e2ce9bf5dffc8aa65296afe6f57097ee9655715dce1c7

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

require 'autotest'

Autotest.add_hook :initialize do |at|
  at.clear_mappings
  # watch out: Ruby bug (1.8.6):
  # %r(/) != /\//
  at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _| 
    filename 
  }
  at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| 
    ["spec/#{m[1]}_spec.rb"]
  }
  at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) { 
    at.files_matching %r%^spec/.*_spec\.rb$%
  }
end

class RspecCommandError < StandardError; end

class Autotest::Rspec < Autotest

  def initialize
    super
    self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
    self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
  end
  
  def consolidate_failures(failed)
    filters = new_hash_of_arrays
    failed.each do |spec, trace|
      if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:/
        filters[$2] << spec
      end
    end
    return filters
  end

  def make_test_cmd(files_to_test)
    return '' if files_to_test.empty?
    spec_program = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
    return "#{ruby} #{spec_program} --autospec #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}"
  end
  
  def add_options_if_present # :nodoc:
    File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
dchelimsky-rspec-1.1.99.13 lib/autotest/rspec.rb
dchelimsky-rspec-1.1.99.7 lib/autotest/rspec.rb
dchelimsky-rspec-1.1.99.8 lib/autotest/rspec.rb
dchelimsky-rspec-1.1.99.9 lib/autotest/rspec.rb
rspec-1.2.0 lib/autotest/rspec.rb
rspec-1.2.1 lib/autotest/rspec.rb
rspec-1.2.2 lib/autotest/rspec.rb
rspec-1.2.6 lib/autotest/rspec.rb
rspec-1.2.5 lib/autotest/rspec.rb
rspec-1.2.4 lib/autotest/rspec.rb
rspec-1.2.3 lib/autotest/rspec.rb