@@ -83,33 +83,36 @@ module RSpec::Core
83
83
]
84
84
end
85
85
86
- it "applies only to examples with matching metadata" do
87
- sequence = [ ]
88
-
89
- group = RSpec . describe do
90
- example ( "" ) { sequence << :ex_1 }
91
- example ( "" , :run_hooks ) { sequence << :ex_2 }
92
- end
86
+ { ":example" => [ :example ] , ":each" => [ :each ] } . each do |label , args |
87
+ args << :run_hooks
88
+ it "applies only to examples with matching metadata (for hooks declared with #{ label } )" do
89
+ sequence = [ ]
90
+
91
+ group = RSpec . describe do
92
+ example ( "" ) { sequence << :ex_1 }
93
+ example ( "" , :run_hooks ) { sequence << :ex_2 }
94
+ end
93
95
94
- RSpec . configure do |c |
95
- c . before ( :example , :run_hooks ) { sequence << :before_ex_2 }
96
- c . prepend_before ( :example , :run_hooks ) { sequence << :before_ex_1 }
96
+ RSpec . configure do |c |
97
+ c . before ( * args ) { sequence << :before_ex_2 }
98
+ c . prepend_before ( * args ) { sequence << :before_ex_1 }
97
99
98
- c . after ( :example , :run_hooks ) { sequence << :after_ex_1 }
99
- c . append_after ( :example , :run_hooks ) { sequence << :after_ex_2 }
100
+ c . after ( * args ) { sequence << :after_ex_1 }
101
+ c . append_after ( * args ) { sequence << :after_ex_2 }
100
102
101
- c . around ( :example , :run_hooks ) do |ex |
102
- sequence << :around_before_ex
103
- ex . run
104
- sequence << :around_after_ex
103
+ c . around ( *args ) do |ex |
104
+ sequence << :around_before_ex
105
+ ex . run
106
+ sequence << :around_after_ex
107
+ end
105
108
end
106
- end
107
109
108
- group . run
109
- expect ( sequence ) . to eq [
110
- :ex_1 ,
111
- :around_before_ex , :before_ex_1 , :before_ex_2 , :ex_2 , :after_ex_1 , :after_ex_2 , :around_after_ex ,
112
- ]
110
+ group . run
111
+ expect ( sequence ) . to eq [
112
+ :ex_1 ,
113
+ :around_before_ex , :before_ex_1 , :before_ex_2 , :ex_2 , :after_ex_1 , :after_ex_2 , :around_after_ex ,
114
+ ]
115
+ end
113
116
end
114
117
115
118
it "does not apply `suite` hooks to groups (or print warnings about suite hooks applied to example groups)" do
0 commit comments