def initialize
super
initialize_test_layout
add_exception %r%^\./(?:doc|log|public|tmp)%
clear_mappings
add_mapping %r%^lib\/.*\.rb% do |filename, _|
files_matching Regexp.new(["^#{model_test_for(filename)}$"])
end
add_mapping %r%^#{fixtures_dir}/(.*)s.yml% do |_, m|
[
model_test_for(m[1]),
controller_test_for(m[1]),
view_test_for(m[1])
]
end
add_mapping %r%^test/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _|
filename
end
add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
model_test_for(m[1])
end
add_mapping %r%^app/helpers/global_helpers.rb% do
files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
end
add_mapping %r%^app/helpers/(.*)_helper(s)?.rb% do |_, m|
if m[1] == "global" then
files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
else
[
view_test_for(m[1]),
controller_test_for(m[1])
]
end
end
add_mapping %r%^app/views/(.*)/% do |_, m|
[
view_test_for(m[1]),
controller_test_for(m[1])
]
end
add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
if ["application", "exception"].include?(m[1])
files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
else
controller_test_for(m[1])
end
end
add_mapping %r%^config/router.rb$% do
files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
end
add_mapping %r%^test/test_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do
files_matching %r%^test/(unit|models|controllers|views|functional)/.*_test\.rb$%
end
end