@@ -13,30 +13,61 @@ def c.escaped_path(*parts)
13
13
Regexp . compile ( parts . join ( '[\\\/]' ) + '[\\\/]' )
14
14
end
15
15
16
- c . include RSpec ::Rails ::ControllerExampleGroup , :type => :controller , :example_group => {
17
- :file_path => c . escaped_path ( %w[ spec controllers ] )
18
- }
19
- c . include RSpec ::Rails ::HelperExampleGroup , :type => :helper , :example_group => {
20
- :file_path => c . escaped_path ( %w[ spec helpers ] )
21
- }
22
- if defined? ( RSpec ::Rails ::MailerExampleGroup )
23
- c . include RSpec ::Rails ::MailerExampleGroup , :type => :mailer , :example_group => {
24
- :file_path => c . escaped_path ( %w[ spec mailers ] )
16
+ controller_path_regex = c . escaped_path ( %w[ spec controllers ] )
17
+ c . include RSpec ::Rails ::ControllerExampleGroup ,
18
+ :type => :controller ,
19
+ :example_group => lambda { |example_group , metadata |
20
+ metadata [ :type ] . nil? && controller_path_regex =~ example_group [ :file_path ]
21
+ }
22
+
23
+ helper_path_regex = c . escaped_path ( %w[ spec helpers ] )
24
+ c . include RSpec ::Rails ::HelperExampleGroup ,
25
+ :type => :helper ,
26
+ :example_group => lambda { |example_group , metadata |
27
+ metadata [ :type ] . nil? && helper_path_regex =~ example_group [ :file_path ]
25
28
}
29
+
30
+ mailer_path_regex = c . escaped_path ( %w[ spec mailers ] )
31
+ if defined? ( RSpec ::Rails ::MailerExampleGroup )
32
+ c . include RSpec ::Rails ::MailerExampleGroup ,
33
+ :type => :mailer ,
34
+ :example_group => lambda { |example_group , metadata |
35
+ metadata [ :type ] . nil? && mailer_path_regex =~ example_group [ :file_path ]
36
+ }
26
37
end
27
- c . include RSpec ::Rails ::ModelExampleGroup , :type => :model , :example_group => {
28
- :file_path => c . escaped_path ( %w[ spec models ] )
29
- }
30
- c . include RSpec ::Rails ::RequestExampleGroup , :type => :request , :example_group => {
31
- :file_path => c . escaped_path ( %w[ spec (requests|integration|api) ] )
32
- }
33
- c . include RSpec ::Rails ::RoutingExampleGroup , :type => :routing , :example_group => {
34
- :file_path => c . escaped_path ( %w[ spec routing ] )
35
- }
36
- c . include RSpec ::Rails ::ViewExampleGroup , :type => :view , :example_group => {
37
- :file_path => c . escaped_path ( %w[ spec views ] )
38
- }
39
- c . include RSpec ::Rails ::FeatureExampleGroup , :type => :feature , :example_group => {
40
- :file_path => c . escaped_path ( %w[ spec features ] )
41
- }
38
+
39
+ model_path_regex = c . escaped_path ( %w[ spec models ] )
40
+ c . include RSpec ::Rails ::ModelExampleGroup ,
41
+ :type => :model ,
42
+ :example_group => lambda { |example_group , metadata |
43
+ metadata [ :type ] . nil? && model_path_regex =~ example_group [ :file_path ]
44
+ }
45
+
46
+ request_path_regex = c . escaped_path ( %w[ spec (requests|integration|api) ] )
47
+ c . include RSpec ::Rails ::RequestExampleGroup ,
48
+ :type => :request ,
49
+ :example_group => lambda { |example_group , metadata |
50
+ metadata [ :type ] . nil? && request_path_regex =~ example_group [ :file_path ]
51
+ }
52
+
53
+ routing_path_regex = c . escaped_path ( %w[ spec routing ] )
54
+ c . include RSpec ::Rails ::RoutingExampleGroup ,
55
+ :type => :routing ,
56
+ :example_group => lambda { |example_group , metadata |
57
+ metadata [ :type ] . nil? && routing_path_regex =~ example_group [ :file_path ]
58
+ }
59
+
60
+ view_path_regex = c . escaped_path ( %w[ spec views ] )
61
+ c . include RSpec ::Rails ::ViewExampleGroup ,
62
+ :type => :view ,
63
+ :example_group => lambda { |example_group , metadata |
64
+ metadata [ :type ] . nil? && view_path_regex =~ example_group [ :file_path ]
65
+ }
66
+
67
+ feature_example_regex = c . escaped_path ( %w[ spec features ] )
68
+ c . include RSpec ::Rails ::FeatureExampleGroup ,
69
+ :type => :feature ,
70
+ :example_group => lambda { |example_group , metadata |
71
+ metadata [ :type ] . nil? && feature_example_regex =~ example_group [ :file_path ]
72
+ }
42
73
end
0 commit comments