From bd9fa17f60af398989ab62216aef99960e182169 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Tue, 17 Dec 2024 10:20:20 -0500 Subject: [PATCH] YNGJ-1058: Be more explicit about teardown. Use public interface rather than reaching into ActiveSupport::Notifications --- .../aether_observatory/event_base_spec.rb | 21 ++++++++++++------- .../aether_observatory/observer_base_spec.rb | 19 ++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/aether_observatory/spec/aether_observatory/event_base_spec.rb b/packages/aether_observatory/spec/aether_observatory/event_base_spec.rb index 2886ee3d..12082b77 100644 --- a/packages/aether_observatory/spec/aether_observatory/event_base_spec.rb +++ b/packages/aether_observatory/spec/aether_observatory/event_base_spec.rb @@ -4,8 +4,6 @@ module AetherObservatory RSpec.describe EventBase do - after(:each) { teardown } - describe ".create" do it "sends event to a single observer" do # Given @@ -22,6 +20,9 @@ module AetherObservatory # Then expect(observer.returned_payload.message).to eq("message") + + # Teardown + observer.stop end it "sends event to multiple observers", :aggregate_failures do @@ -45,6 +46,10 @@ module AetherObservatory # Then expect(observer_zero.returned_payload.message).to eq("message") expect(observer_both.returned_payload.message).to eq("message") + + # Teardown + observer_zero.stop + observer_both.stop end it "sends event to only one of multiple observers", :aggregate_failures do @@ -68,6 +73,10 @@ module AetherObservatory # Then expect(observer_zero.returned_payload).to eq(nil) expect(observer_both.returned_payload.message).to eq("message") + + # Teardown + observer_zero.stop + observer_both.stop end context "without a prefix" do @@ -85,6 +94,9 @@ module AetherObservatory # Then expect(observer.returned_payload.message).to eq("message") + + # Teardown + observer.stop end end end @@ -122,10 +134,5 @@ def process end ) end - - def teardown - ActiveSupport::Notifications.notifier = - ActiveSupport::Notifications::Fanout.new - end end end diff --git a/packages/aether_observatory/spec/aether_observatory/observer_base_spec.rb b/packages/aether_observatory/spec/aether_observatory/observer_base_spec.rb index 01758f1a..d1d9a587 100644 --- a/packages/aether_observatory/spec/aether_observatory/observer_base_spec.rb +++ b/packages/aether_observatory/spec/aether_observatory/observer_base_spec.rb @@ -4,8 +4,6 @@ module AetherObservatory RSpec.describe ObserverBase do - after(:each) { teardown } - describe "#process" do it "processes a single event" do # Given @@ -19,6 +17,9 @@ module AetherObservatory # Then expect(observer.returned_payload.message).to eq("message") + + # Teardown + observer.stop end it "processed multiple events", :aggregate_failures do @@ -40,6 +41,9 @@ module AetherObservatory # Then expect(observer.returned_payload.message).to eq("message one") + + # Teardown + observer.stop end end @@ -56,6 +60,9 @@ module AetherObservatory # Then expect(observer.returned_payload).to eq(nil) + + # Teardown + observer.stop end end @@ -72,6 +79,9 @@ module AetherObservatory # Then expect(observer.returned_payload.message).to eq("message") + + # Teardown + observer.stop end end @@ -104,10 +114,5 @@ def process end ) end - - def teardown - ActiveSupport::Notifications.notifier = - ActiveSupport::Notifications::Fanout.new - end end end