Skip to content

Commit 70cb9e4

Browse files
p-mongop
andauthored
Use RSpec.current_example instead of duplicating that implementation in our code (#2559)
Co-authored-by: Oleg Pudeyev <code@olegp.name>
1 parent b9e84a8 commit 70cb9e4

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

spec/support/background_thread_registry.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def register(object, thread)
3030
@records << OpenStruct.new(
3131
thread: thread,
3232
object: object,
33-
example: $current_example,
33+
# When rake spec:prepare is run, the current_example method is not defined
34+
example: RSpec.respond_to?(:current_example) ? RSpec.current_example : nil,
3435
)
3536
end
3637
end
@@ -46,7 +47,7 @@ def verify_empty!
4647
msg << "\n with options: #{record.object.options}"
4748
end
4849
if record.example
49-
msg << "\n in #{record.example.id} #{record.example.full_description}"
50+
msg << "\n in #{record.example.id}: #{record.example.full_description}"
5051
else
5152
msg << "\n not in an example"
5253
end
@@ -57,14 +58,3 @@ def verify_empty!
5758
end
5859
end
5960
end
60-
61-
RSpec.configure do |config|
62-
config.around do |example|
63-
$current_example = example
64-
begin
65-
example.run
66-
ensure
67-
$current_example = nil
68-
end
69-
end
70-
end

0 commit comments

Comments
 (0)