# File lib/generators/templates/application/merb_stack/autotest/merb_rspec.rb, line 13
  def initialize
    super

    # Ignore any happenings in these directories
    add_exception %r%^\./(?:doc|log|public|tmp|\.git|\.hg|\.svn|framework|gems|schema|\.DS_Store|autotest|bin|.*\.sqlite3|.*\.thor)% 
    # Ignore SCM directories and custom Autotest mappings
    %w[.svn .hg .git .autotest].each { |exception| add_exception(exception) }

    # Ignore any mappings that Autotest may have already set up
    clear_mappings

    # Anything in /lib could have a spec anywhere, if at all. So, look for
    # files with roughly the same name as the file in /lib
    add_mapping %r%^lib\/(.*)\.rb% do |_, m|
      files_matching %r%^spec\/#{m[1]}%
    end

    add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do
      all_specs
    end

    # Changing a spec will cause it to run itself
    add_mapping %r%^spec/.*\.rb$% do |filename, _|
      filename
    end

    # Any change to a model will cause it's corresponding test to be run
    add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
      spec_for(m[1], 'model')
    end

    # Any change to global_helpers will result in all view and controller
    # tests being run
    add_mapping %r%^app/helpers/global_helpers\.rb% do
      files_matching %r%^spec/(views|controllers|helpers|requests)/.*_spec\.rb$%
    end

    # Any change to a helper will cause its spec to be run
    add_mapping %r%^app/helpers/((.*)_helper(s)?)\.rb% do |_, m|
      spec_for(m[1], 'helper')
    end

    # Changes to a view cause its spec to be run
    add_mapping %r%^app/views/(.*)/% do |_, m|
      spec_for(m[1], 'view')
    end

    # Changes to a controller result in its corresponding spec being run. If
    # the controller is the exception or application controller, all
    # controller specs are run.
    add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
      if ["application", "exception"].include?(m[1])
        files_matching %r%^spec/controllers/.*_spec\.rb$%
      else
        spec_for(m[1], 'controller')
      end
    end

    # If a change is made to the router, run controller, view and helper specs
    add_mapping %r%^config/router.rb$% do
      files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
    end

    # If any of the major files governing the environment are altered, run
    # everything
    add_mapping %r%^config/(init|rack|environments/test).*\.rb|database\.yml% do 
      all_specs
    end
  end