Sha256: 15f344fac143999eef102052b0d2ffe1644d55d59d2c7b93015aafc694657be2

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'autotest'

class RailsAutotest < Autotest

  def initialize # :nodoc:
    super
    @exceptions = %r%^\./(?:db|doc|log|public|script|vendor/rails)%
  end

  def tests_for_file(filename)

    case filename
    when %r%^test/fixtures/(.*)s.yml% then
      ["test/unit/#{$1}_test.rb",
       "test/controllers/#{$1}_controller_test.rb",
       "test/views/#{$1}_view_test.rb",
       "test/functional/#{$1}_controller_test.rb"]
    when %r%^test/(unit|integration|controllers|views|functional)/.*rb$% then
      [filename]
    when %r%^app/models/(.*)\.rb$% then
      ["test/unit/#{$1}_test.rb"]
    when %r%^app/helpers/application_helper.rb% then
      @files.keys.select { |f|
        f =~ %r%^test/(views|functional)/.*_test\.rb$%
      }
    when %r%^app/helpers/(.*)_helper.rb%, %r%^app/views/(.*)/% then
      ["test/views/#{$1}_view_test.rb",
       "test/functional/#{$1}_controller_test.rb"]
    when %r%^app/controllers/application.rb$% then # FIX: wtf?
      ["test/controllers/dummy_controller_test.rb",
       "test/functional/dummy_controller_test.rb"]
    when %r%^app/controllers/(.*)\.rb$% then
      ["test/controllers/#{$1}_test.rb",
       "test/functional/#{$1}_test.rb"]
    when %r%^app/views/layouts/% then
      ["test/views/layouts_view_test.rb"]
    when %r%^config/routes.rb$% then
      @files.keys.select do |f|
        f =~ %r%^test/(controllers|views|functional)/.*_test\.rb$%
      end
    when %r%^test/test_helper.rb%,
         %r%^config/((boot|environment(s/test)?).rb|database.yml)% then
      @files.keys.select do |f|
        f =~ %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
      end
    else
      @output.puts "Dunno! #{filename}" if $TESTING
      []
    end.uniq.select { |f| @files.has_key? f }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ZenTest-3.4.0 lib/rails_autotest.rb