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