10000 Copy over rspec context to reactor thread. (#22) · socketry/async-rspec@048847a · GitHub
[go: up one dir, main page]

Skip to content

Commit 048847a

Browse files
authored
Copy over rspec context to reactor thread. (#22)
1 parent 66f0ac8 commit 048847a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/async/rspec/reactor.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def run_in_reactor(reactor, duration = nil)
7878
include Reactor
7979
let(:reactor) {@reactor}
8080

81+
rspec_context = Thread.current[:__rspec]
8182
include_context Async::RSpec::Leaks
8283

8384
around(:each) do |example|
@@ -90,6 +91,7 @@ def run_in_reactor(reactor, duration = nil)
9091
task.annotate(self.class)
9192

9293
run_in_reactor(@reactor, duration) do
94+
Thread.current[:__rspec] = rspec_context
9395
example.run
9496
end
9597
ensure

spec/async/rspec/reactor_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,13 @@
8282
# end.to raise_error("Boom!")
8383
# end
8484
end
85+
86+
context "rspec metadata", timeout: 1 do
87+
include_context Async::RSpec::Reactor
88+
89+
it "should have access to example metadata" do
90+
expect(RSpec.current_example).not_to be_nil
91+
expect(RSpec.current_example.metadata[:described_class]).to eq(Async::RSpec::Reactor)
92+
end
93+
end
8594
end

0 commit comments

Comments
 (0)
0