1 # (c) Copyright 2006 Nick Sieger <nicksieger@gmail.com>
3 # Permission is hereby granted, free of charge, to any person
4 # obtaining a copy of this software and associated documentation files
5 # (the "Software"), to deal in the Software without restriction,
6 # including without limitation the rights to use, copy, modify, merge,
7 # publish, distribute, sublicense, and/or sell copies of the Software,
8 # and to permit persons to whom the Software is furnished to do so,
9 # subject to the following conditions:
11 # The above copyright notice and this permission notice shall be
12 # included in all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 $:.push(*Dir["vendor/rails/*/lib"])
25 require 'active_support'
26 require 'autotest/rspec'
28 class Autotest::RailsRspec < Autotest::Rspec
30 def initialize # :nodoc:
32 @exceptions = %r%^\./(?:coverage|db|doc|log|public|script|vendor\/rails|previous_failures.txt)%
34 %r%^(test|spec)/fixtures/(.*).yml$% => proc { |_, m|
35 ["spec/models/#{m[2].singularize}_spec.rb"] + files_matching(%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%)
37 %r%^spec/(models|controllers|views|helpers|lib)/.*rb$% => proc { |filename, _|
40 %r%^app/models/(.*)\.rb$% => proc { |_, m|
41 ["spec/models/#{m[1]}_spec.rb"]
43 %r%^app/views/(.*)$% => proc { |_, m|
44 files_matching %r%^spec/views/#{m[1]}_spec.rb$%
46 %r%^app/controllers/(.*)\.rb$% => proc { |_, m|
47 ["spec/controllers/#{m[1]}_spec.rb"]
49 %r%^app/helpers/(.*)_helper\.rb$% => proc { |_, m|
50 if m[1] == "application" then
51 files_matching(%r%^spec/(views|helpers)/.*_spec\.rb$%)
53 ["spec/helpers/#{m[1]}_helper_spec.rb"] + files_matching(%r%^spec\/views\/#{m[1]}/.*_spec\.rb$%)
56 %r%^app/helpers/application_helper\.rb$% => proc {
57 files_matching %r%^spec/(views|helpers)/.*_spec\.rb$%
59 %r%^app/controllers/application\.rb$% => proc { |_, m|
60 files_matching %r%^spec/controllers/.*_spec\.rb$%
62 %r%^config/routes\.rb$% => proc {
63 files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
65 %r%^config/database\.yml$% => proc { |_, m|
66 files_matching %r%^spec/models/.*_spec\.rb$%
68 %r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$% => proc {
69 files_matching %r%^spec/(models|controllers|views|helpers)/.*_spec\.rb$%
71 %r%^lib/(.*)\.rb$% => proc { |_, m|
72 ["spec/lib/#{m[1]}_spec.rb"]