changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb

changeset 16: 01fd3f10ae84
author: moriq@moriq.com
date: Mon Mar 10 10:13:18 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec_on_rails
1# (c) Copyright 2006 Nick Sieger <nicksieger@gmail.com>
2#
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:
10#
11# The above copyright notice and this permission notice shall be
12# included in all copies or substantial portions of the Software.
13#
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.
22
23$:.push(*Dir["vendor/rails/*/lib"])
24
25require 'active_support'
26require 'autotest/rspec'
27
28Autotest.add_hook :initialize do |at|
29 %w{^config/ ^coverage/ ^db/ ^doc/ ^log/ ^public/ ^script ^vendor/rails ^vendor/plugins previous_failures.txt}.each do |exception|
30 at.add_exception(exception)
31 end
32
33 at.clear_mappings
34
35 at.add_mapping(%r%^(test|spec)/fixtures/(.*).yml$%) { |_, m|
36 ["spec/models/#{m[2].singularize}_spec.rb"] + at.files_matching(%r%^spec\/views\/#{m[2]}/.*_spec\.rb$%)
37 }
38 at.add_mapping(%r%^spec/(models|controllers|views|helpers|lib)/.*rb$%) { |filename, _|
39 filename
40 }
41 at.add_mapping(%r%^app/models/(.*)\.rb$%) { |_, m|
42 ["spec/models/#{m[1]}_spec.rb"]
43 }
44 at.add_mapping(%r%^app/views/(.*)$%) { |_, m|
45 at.files_matching %r%^spec/views/#{m[1]}_spec.rb$%
46 }
47 at.add_mapping(%r%^app/controllers/(.*)\.rb$%) { |_, m|
48 if m[1] == "application"
49 at.files_matching %r%^spec/controllers/.*_spec\.rb$%
50 else
51 ["spec/controllers/#{m[1]}_spec.rb"]
52 end
53 }
54 at.add_mapping(%r%^app/helpers/(.*)_helper\.rb$%) { |_, m|
55 if m[1] == "application" then
56 at.files_matching(%r%^spec/(views|helpers)/.*_spec\.rb$%)
57 else
58 ["spec/helpers/#{m[1]}_helper_spec.rb"] + at.files_matching(%r%^spec\/views\/#{m[1]}/.*_spec\.rb$%)
59 end
60 }
61 at.add_mapping(%r%^config/routes\.rb$%) {
62 at.files_matching %r%^spec/(controllers|views|helpers)/.*_spec\.rb$%
63 }
64 at.add_mapping(%r%^config/database\.yml$%) { |_, m|
65 at.files_matching %r%^spec/models/.*_spec\.rb$%
66 }
67 at.add_mapping(%r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$%) {
68 at.files_matching %r%^spec/(models|controllers|views|helpers)/.*_spec\.rb$%
69 }
70 at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
71 ["spec/lib/#{m[1]}_spec.rb"]
72 }
73end
74
75class Autotest::RailsRspec < Autotest::Rspec
76
77 def spec_command
78 "script/spec"
79 end
80
81end