diff --git a/lib/async/rspec/reactor.rb b/lib/async/rspec/reactor.rb index d78ff4a..0c5cba3 100644 --- a/lib/async/rspec/reactor.rb +++ b/lib/async/rspec/reactor.rb @@ -78,6 +78,7 @@ def run_in_reactor(reactor, duration = nil) include Reactor let(:reactor) {@reactor} + rspec_context = Thread.current[:__rspec] include_context Async::RSpec::Leaks around(:each) do |example| @@ -90,6 +91,7 @@ def run_in_reactor(reactor, duration = nil) task.annotate(self.class) run_in_reactor(@reactor, duration) do + Thread.current[:__rspec] = rspec_context example.run end ensure diff --git a/spec/async/rspec/reactor_spec.rb b/spec/async/rspec/reactor_spec.rb index 7529218..1a6558a 100644 --- a/spec/async/rspec/reactor_spec.rb +++ b/spec/async/rspec/reactor_spec.rb @@ -82,4 +82,13 @@ # end.to raise_error("Boom!") # end end + + context "rspec metadata", timeout: 1 do + include_context Async::RSpec::Reactor + + it "should have access to example metadata" do + expect(RSpec.current_example).not_to be_nil + expect(RSpec.current_example.metadata[:described_class]).to eq(Async::RSpec::Reactor) + end + end end