Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / rspec_on_rails / lib / autotest / rails_rspec.rb
blob994b9f68e7108fde5c8f9a4477c3a597837788f8
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
21 # SOFTWARE.
23 $:.push(*Dir["vendor/rails/*/lib"])
25 require 'active_support'
26 require 'autotest/rspec'
28 class Autotest::RailsRspec < Autotest::Rspec
30   def initialize # :nodoc:
31     super
32     @exceptions = %r%^\./(?:coverage|db|doc|log|public|script|vendor\/rails|previous_failures.txt)%
33     @test_mappings = {
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$%)
36       },
37       %r%^spec/(models|controllers|views|helpers|lib)/.*rb$% => proc { |filename, _|
38         filename
39       },
40       %r%^app/models/(.*)\.rb$% => proc { |_, m|
41         ["spec/models/#{m[1]}_spec.rb"]
42       },
43       %r%^app/views/(.*)$% => proc { |_, m|
44         files_matching %r%^spec/views/#{m[1]}_spec.rb$%
45       },
46       %r%^app/controllers/(.*)\.rb$% => proc { |_, m|
47         ["spec/controllers/#{m[1]}_spec.rb"]
48       },
49       %r%^app/helpers/(.*)_helper\.rb$% => proc { |_, m|
50         if m[1] == "application" then
51           files_matching(%r%^spec/(views|helpers)/.*_spec\.rb$%)
52         else
53           ["spec/helpers/#{m[1]}_helper_spec.rb"] + files_matching(%r%^spec\/views\/#{m[1]}/.*_spec\.rb$%)
54         end
55       },
56       %r%^app/helpers/application_helper\.rb$% => proc {
57         files_matching %r%^spec/(views|helpers)/.*_spec\.rb$%
58       },
59       %r%^app/controllers/application\.rb$% => proc { |_, m|
60         files_matching %r%^spec/controllers/.*_spec\.rb$%
61       },
62       %r%^config/routes\.rb$% => proc {
63         files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
64       },
65       %r%^config/database\.yml$% => proc { |_, m|
66         files_matching %r%^spec/models/.*_spec\.rb$%
67       },
68       %r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$% => proc {
69         files_matching %r%^spec/(models|controllers|views|helpers)/.*_spec\.rb$%
70       },
71       %r%^lib/(.*)\.rb$% => proc { |_, m|
72         ["spec/lib/#{m[1]}_spec.rb"]
73       },
74     }    
75   end
76   
77   def spec_command
78     "script/spec"
79   end
80     
81 end