Skip to content

Commit

Permalink
! Updated rules for rails 4. (blowmage)
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/autotest-rails/dev/": change = 9041]
  • Loading branch information
zenspider committed Nov 21, 2013
1 parent 13806c1 commit ab39bd5
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions lib/autotest/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,40 @@ def initialize # :nodoc:

clear_mappings

self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
impl = File.basename(filename, '.rb')
files_matching %r%^test/unit/#{impl}_test.rb$%
add_mapping %r%^lib/(.*)\.rb$% do |_, m|
files_matching %r%^test/(lib|unit/lib)/#{m[1]}.*_test.rb$%
# TODO: (unit|functional|integration) maybe?
end

add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
["test/unit/#{m[1]}_test.rb",
"test/controllers/#{m[1]}_controller_test.rb",
"test/views/#{m[1]}_view_test.rb",
"test/functional/#{m[1]}_controller_test.rb"]
files_matching %r%^test/(models|controllers|views|unit|functional)/#{m[1]}.*_test.rb$%
end

add_mapping %r%^test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _|
add_mapping %r%^test/.*_test\.rb$% do |filename, _|
filename
end

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

add_mapping %r%^app/helpers/application_helper.rb% do
files_matching %r%^test/(views|functional)/.*_test\.rb$%
files_matching %r%^test/(models|unit)/#{m[1]}.*_test.rb$%
end

add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
if m[1] == "application" then
files_matching %r%^test/(views|functional)/.*_test\.rb$%
files_matching %r%^test/(helpers|controllers|views|unit/helpers/functional)/.*_test\.rb$%
else
["test/views/#{m[1]}_view_test.rb",
"test/functional/#{m[1]}_controller_test.rb"]
files_matching %r%^test/(helpers|controllers|views|unit/helpers/functional)/#{m[1]}.*_test.rb$%
end
end

add_mapping %r%^app/views/(.*)/% do |_, m|
["test/views/#{m[1]}_view_test.rb",
"test/functional/#{m[1]}_controller_test.rb"]
files_matching %r%^test/(controllers|views|functional)/#{m[1]}.*_test.rb$%
end

add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
if m[1] == "application" then
files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
else
["test/controllers/#{m[1]}_test.rb",
"test/functional/#{m[1]}_test.rb"]
files_matching %r%^test/(controllers|views|functional)/#{m[1]}.*_test.rb$%
end
end

Expand All @@ -63,11 +52,11 @@ def initialize # :nodoc:
end

add_mapping %r%^config/routes.rb$% do # FIX:
files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
files_matching %r%^test/(integration|controllers|views|functional)/.*_test\.rb$%
end

add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
files_matching %r%^test/(models|controllers|views|unit|functional)/#{m[1]}.*_test.rb$%
end
end

Expand Down

0 comments on commit ab39bd5

Please sign in to comment.