model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
model_tests_dir | the directory to find model-centric tests |
controller_tests_dir | the directory to find controller-centric tests |
view_tests_dir | the directory to find view-centric tests |
fixtures_dir | the directory to find fixtures in |
# File lib/generators/templates/application/merb_stack/autotest/merb.rb, line 12 12: def initialize 13: super 14: 15: initialize_test_layout 16: 17: # Ignore any happenings in these directories 18: add_exception %^\./(?:doc|log|public|tmp|\.git|\.hg|\.svn|framework|gems|schema|\.DS_Store|autotest|bin|.*\.sqlite3)% 19: # Ignore SCM directories and custom Autotest mappings 20: ].svn .hg .git .autotest].each { |exception| add_exception(exception) } 21: 22: 23: # Ignore any mappings that Autotest may have already set up 24: clear_mappings 25: 26: # Any changes to a file in the root of the 'lib' directory will run any 27: # model test with a corresponding name. 28: add_mapping %^lib\/.*\.rb% do |filename, _| 29: files_matching Regexp.new(["^#{model_test_for(filename)}$"]) 30: end 31: 32: # Any changes to a fixture will run corresponding view, controller and 33: # model tests 34: add_mapping %^#{fixtures_dir}/(.*)s.yml% do |_, m| 35: [ 36: model_test_for(m[1]), 37: controller_test_for(m[1]), 38: view_test_for(m[1]) 39: ] 40: end 41: 42: # Any change to a test will cause it to be run 43: add_mapping %^test/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _| 44: filename 45: end 46: 47: # Any change to a model will cause it's corresponding test to be run 48: add_mapping %^app/models/(.*)\.rb$% do |_, m| 49: model_test_for(m[1]) 50: end 51: 52: # Any change to the global helper will result in all view and controller 53: # tests being run 54: add_mapping %^app/helpers/global_helpers.rb% do 55: files_matching %^test/(views|functional|controllers)/.*_test\.rb$% 56: end 57: 58: # Any change to a helper will run it's corresponding view and controller 59: # tests, unless the helper is the global helper. Changes to the global 60: # helper run all view and controller tests. 61: add_mapping %^app/helpers/(.*)_helper(s)?.rb% do |_, m| 62: if m[1] == "global" then 63: files_matching %^test/(views|functional|controllers)/.*_test\.rb$% 64: else 65: [ 66: view_test_for(m[1]), 67: controller_test_for(m[1]) 68: ] 69: end 70: end 71: 72: # Changes to views result in their corresponding view and controller test 73: # being run 74: add_mapping %^app/views/(.*)/% do |_, m| 75: [ 76: view_test_for(m[1]), 77: controller_test_for(m[1]) 78: ] 79: end 80: 81: # Changes to a controller result in its corresponding test being run. If 82: # the controller is the exception or application controller, all 83: # controller tests are run. 84: add_mapping %^app/controllers/(.*)\.rb$% do |_, m| 85: if ["application", "exception"].include?(m[1]) 86: files_matching %^test/(controllers|views|functional)/.*_test\.rb$% 87: else 88: controller_test_for(m[1]) 89: end 90: end 91: 92: # If a change is made to the router, run all controller and view tests 93: add_mapping %^config/router.rb$% do # FIX 94: files_matching %^test/(controllers|views|functional)/.*_test\.rb$% 95: end 96: 97: # If any of the major files governing the environment are altered, run 98: # everything 99: add_mapping %^test/test_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX 100: files_matching %^test/(unit|models|controllers|views|functional)/.*_test\.rb$% 101: end 102: end
# File lib/generators/templates/application/merb_core/autotest/merb.rb, line 12 12: def initialize 13: super 14: 15: initialize_test_layout 16: 17: # Ignore any happenings in these directories 18: add_exception %^\./(?:doc|log|public|tmp)% 19: 20: # Ignore any mappings that Autotest may have already set up 21: clear_mappings 22: 23: # Any changes to a file in the root of the 'lib' directory will run any 24: # model test with a corresponding name. 25: add_mapping %^lib\/.*\.rb% do |filename, _| 26: files_matching Regexp.new(["^#{model_test_for(filename)}$"]) 27: end 28: 29: # Any changes to a fixture will run corresponding view, controller and 30: # model tests 31: add_mapping %^#{fixtures_dir}/(.*)s.yml% do |_, m| 32: [ 33: model_test_for(m[1]), 34: controller_test_for(m[1]), 35: view_test_for(m[1]) 36: ] 37: end 38: 39: # Any change to a test or test will cause it to be run 40: add_mapping %^test/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _| 41: filename 42: end 43: 44: # Any change to a model will cause it's corresponding test to be run 45: add_mapping %^app/models/(.*)\.rb$% do |_, m| 46: model_test_for(m[1]) 47: end 48: 49: # Any change to the global helper will result in all view and controller 50: # tests being run 51: add_mapping %^app/helpers/global_helpers.rb% do 52: files_matching %^test/(views|functional|controllers)/.*_test\.rb$% 53: end 54: 55: # Any change to a helper will run it's corresponding view and controller 56: # tests, unless the helper is the global helper. Changes to the global 57: # helper run all view and controller tests. 58: add_mapping %^app/helpers/(.*)_helper(s)?.rb% do |_, m| 59: if m[1] == "global" then 60: files_matching %^test/(views|functional|controllers)/.*_test\.rb$% 61: else 62: [ 63: view_test_for(m[1]), 64: controller_test_for(m[1]) 65: ] 66: end 67: end 68: 69: # Changes to views result in their corresponding view and controller test 70: # being run 71: add_mapping %^app/views/(.*)/% do |_, m| 72: [ 73: view_test_for(m[1]), 74: controller_test_for(m[1]) 75: ] 76: end 77: 78: # Changes to a controller result in its corresponding test being run. If 79: # the controller is the exception or application controller, all 80: # controller tests are run. 81: add_mapping %^app/controllers/(.*)\.rb$% do |_, m| 82: if ["application", "exception"].include?(m[1]) 83: files_matching %^test/(controllers|views|functional)/.*_test\.rb$% 84: else 85: controller_test_for(m[1]) 86: end 87: end 88: 89: # If a change is made to the router, run all controller and view tests 90: add_mapping %^config/router.rb$% do # FIX 91: files_matching %^test/(controllers|views|functional)/.*_test\.rb$% 92: end 93: 94: # If any of the major files governing the environment are altered, run 95: # everything 96: add_mapping %^test/test_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX 97: files_matching %^test/(unit|models|controllers|views|functional)/.*_test\.rb$% 98: end 99: end
# File lib/generators/templates/application/merb_core/autotest/merb.rb, line 141 141: def controller_test_for(filename) 142: [controller_tests_dir, test_for(filename, :controller)].join("/") 143: end
# File lib/generators/templates/application/merb_stack/autotest/merb.rb, line 144 144: def controller_test_for(filename) 145: [controller_tests_dir, test_for(filename, :controller)].join("/") 146: end
Determines the paths we can expect tests or specs to reside, as well as corresponding fixtures.
# File lib/generators/templates/application/merb_core/autotest/merb.rb, line 105 105: def initialize_test_layout 106: self.model_tests_dir = "test/unit" 107: self.controller_tests_dir = "test/functional" 108: self.view_tests_dir = "test/views" 109: self.fixtures_dir = "test/fixtures" 110: end
Determines the paths we can expect tests or specs to reside, as well as corresponding fixtures.
# File lib/generators/templates/application/merb_stack/autotest/merb.rb, line 108 108: def initialize_test_layout 109: self.model_tests_dir = "test/unit" 110: self.controller_tests_dir = "test/functional" 111: self.view_tests_dir = "test/views" 112: self.fixtures_dir = "test/fixtures" 113: end
# File lib/generators/templates/application/merb_stack/autotest/merb.rb, line 140 140: def model_test_for(filename) 141: [model_tests_dir, test_for(filename, :model)].join("/") 142: end
# File lib/generators/templates/application/merb_core/autotest/merb.rb, line 137 137: def model_test_for(filename) 138: [model_tests_dir, test_for(filename, :model)].join("/") 139: end
Given a filename and the test type, this method will return the corresponding test’s or spec’s name.
filename | the file name of the model, view, or controller |
kind_of_test | the type of test we that we should run |
String | the name of the corresponding test or spec |
> test_for("user", :model) => "user_test.rb" > test_for("login", :controller) => "login_controller_test.rb" > test_for("form", :view) => "form_view_spec.rb" # If you're running a RSpec-like suite
# File lib/generators/templates/application/merb_stack/autotest/merb.rb, line 133 133: def test_for(filename, kind_of_test) 134: name = [filename] 135: name << kind_of_test.to_s if kind_of_test == :view 136: name << "test" 137: return name.join("_") + ".rb" 138: end
Given a filename and the test type, this method will return the corresponding test’s or spec’s name.
filename | the file name of the model, view, or controller |
kind_of_test | the type of test we that we should run |
String | the name of the corresponding test or spec |
> test_for("user", :model) => "user_test.rb" > test_for("login", :controller) => "login_controller_test.rb" > test_for("form", :view) => "form_view_spec.rb" # If you're running a RSpec-like suite
# File lib/generators/templates/application/merb_core/autotest/merb.rb, line 130 130: def test_for(filename, kind_of_test) 131: name = [filename] 132: name << kind_of_test.to_s if kind_of_test == :view 133: name << "test" 134: return name.join("_") + ".rb" 135: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.