Sha256: 59e1cea35735c93cd1126451535636fbe5b5e2749570e3cd5d9dcac460de18a6

Contents?: true

Size: 1.5 KB

Versions: 11

Compression:

Stored size: 1.5 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

BAR       = "=" * 78
REDCODE   = 31
GREENCODE = 32

Autotest.add_hook :ran_command do |at|
  at.results.last =~ /^.* (\d+) failures, (\d+) errors/

  code = ($1 == "0" and $2 == "0") ? GREENCODE : REDCODE
  puts "\e[#{ code }m#{ BAR }\e[0m\n\n"
end

class Autotest::Spec < Autotest
  def path_to_classname(s)
    sep = File::SEPARATOR
    f = s.sub(/spec#{sep}/, '').sub(/(spec)?\.rb$/, '').split(sep)
    f = f.map { |path| path.split(/_|(\d+)/).map { |seg| seg.capitalize }.join }
    f = f.delete_if { |path| path == 'Core' }
    f.join
  end

  ##
  # Returns a hash mapping a file name to the known failures for that
  # file.

  def consolidate_failures(failed)
    filters = new_hash_of_arrays

    class_map = Hash[*self.find_order.grep(/^spec/).map { |f| # TODO: ugly
                       [path_to_classname(f), f]
                     }.flatten]
    class_map.merge!(self.extra_class_map)

    failed.each do |method, klass|
      if class_map.has_key? klass then
        filters[class_map[klass]] << method
      else
        output.puts "Unable to map class #{klass} to a file"
      end
    end

    return filters
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
sprsquish-blather-0.1 lib/autotest/spec.rb
sprsquish-blather-0.2.3 lib/autotest/spec.rb
sprsquish-rainpress-0.0.0 lib/autotest/spec.rb
sprsquish-rainpress-1.0.0 lib/autotest/spec.rb
sprsquish-rainpress-1.0 lib/autotest/spec.rb
blather-0.2.2 lib/autotest/spec.rb
blather-0.1 lib/autotest/spec.rb
blather-0.2.1 lib/autotest/spec.rb
blather-0.2.3 lib/autotest/spec.rb
blather-0.2 lib/autotest/spec.rb
rainpress-1.0 lib/autotest/spec.rb