Sha256: 0c8e69fd8fdbe32c4dab541b7f9198fc815098688d1fd20a43f623f3ce57582e

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'autotest'

class Autotest::Gem < Autotest
  def initialize # :nodoc:
    super

    add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor)%

    clear_mappings

    add_mapping %r%^lib/(.*)\.rb$% do |_, m|
      ["test/#{m[1].gsub(/\//,"_")}_test.rb"]
    end


    
    add_mapping %r%^test/factories/(.*)_factory.rb% do |_, m|
      ["test/#{m[1]}_test.rb"]
    end


    add_mapping %r%^test/(.*)_test.rb% do |_, m|
      ["test/#{m[1]}_test.rb"]
    end


    add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
      files_matching %r%^test/.*_test\.rb$%
    end


    add_mapping %r%^test/factories.rb|test/blueprints.rb|test/test_helper.rb|(.*)\.gemspec% do
      files_matching %r%^test/.*_test\.rb$%
    end
  end

  # Convert the pathname s to the name of class.
  def path_to_classname(s)
    sep = File::SEPARATOR
    f = s.sub(/^test#{sep}((unit|functional|integration|views|controllers|helpers)#{sep})?/, '').sub(/\.rb$/, '').split(sep)
    f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
    f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test"  }
    f.join('::')
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
tastyhat-autotest-gem-0.1.2 lib/autotest/gem.rb
autotest-gem-0.1.2 lib/autotest/gem.rb