File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,10 @@ def self.extract_spec_location(metadata)
33
33
location = metadata [ :location ]
34
34
35
35
until spec_path? ( location )
36
- metadata = metadata [ :example_group ]
36
+ metadata = metadata [ :parent_example_group ] || metadata [ : example_group]
37
37
38
38
unless metadata
39
- STDERR . puts "no spec file found for #{ root_metadata [ :location ] } "
39
+ STDERR . puts "no spec file location in #{ root_metadata . inspect } "
40
40
return root_metadata [ :location ]
41
41
end
42
42
Original file line number Diff line number Diff line change @@ -145,13 +145,43 @@ def expected_output(spec_filename)
145
145
}
146
146
147
147
expect ( STDERR ) . to receive ( :puts ) .
148
- with ( "no spec file found for #{ metadata [ :location ] } " ) { }
148
+ with ( "no spec file location in #{ metadata . inspect } " )
149
149
150
150
expect ( described_class . extract_spec_location ( metadata ) ) .
151
151
to eq metadata [ :location ]
152
152
end
153
153
end
154
154
155
+ context "when a shared examples are nested" do
156
+ it "should return location of the root spec" do
157
+ metadata = {
158
+ location : "./spec/support/breadcrumbs.rb:75" ,
159
+ example_group : {
160
+ example_group : {
161
+ location : "./spec/requests/breadcrumbs_spec.rb:218"
162
+ }
163
+ }
164
+ }
165
+
166
+ expect ( described_class . extract_spec_location ( metadata ) ) .
167
+ to eq "./spec/requests/breadcrumbs_spec.rb"
168
+ end
169
+ end
170
+
171
+ context "when RSpec 3.0 metadata is present" do
172
+ it "should return location of the root spec" do
173
+ metadata = {
174
+ location : "./spec/support/breadcrumbs.rb:75" ,
175
+ parent_example_group : {
176
+ location : "./spec/requests/breadcrumbs_spec.rb:218"
177
+ }
178
+ }
179
+
180
+ expect ( described_class . extract_spec_location ( metadata ) ) .
181
+ to eq "./spec/requests/breadcrumbs_spec.rb"
182
+ end
183
+ end
184
+
155
185
context "with only success" do
156
186
it "notifies success" do
157
187
formatter . dump_summary ( *summary_with_no_failures )
You can’t perform that action at this time.
0 commit comments