Sha256: fff06deee50352b31b4ea6290a2f5e5e8fb74fc9c3fb8f870802f52e5e31352d

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 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/.*\.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)?(?:.*?Error 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]+:\Z?/
        filters[$2] << spec
      end
    end
    return filters
  end

  def make_test_cmd(files_to_test)
    return '' if files_to_test.empty?
    return "#{ruby} -S #{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

9 entries across 9 versions & 3 rubygems

Version Path
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/lib/autotest/rspec.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/lib/autotest/rspec.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/lib/autotest/rspec.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/lib/autotest/rspec.rb
pictrails-0.5.0 vendor/plugins/rspec/lib/autotest/rspec.rb
rspec-1.1.5 lib/autotest/rspec.rb
rspec-1.1.7 lib/autotest/rspec.rb
rspec-1.1.6 lib/autotest/rspec.rb
rspec-1.1.8 lib/autotest/rspec.rb