Skip to content

Commit

Permalink
YNGJ-1058: Be more explicit about teardown.
Browse files Browse the repository at this point in the history
Use public interface rather than reaching into ActiveSupport::Notifications
  • Loading branch information
dutchess committed Dec 17, 2024
1 parent 59a4a58 commit bd9fa17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -85,6 +94,9 @@ module AetherObservatory

# Then
expect(observer.returned_payload.message).to eq("message")

# Teardown
observer.stop
end
end
end
Expand Down Expand Up @@ -122,10 +134,5 @@ def process
end
)
end

def teardown
ActiveSupport::Notifications.notifier =
ActiveSupport::Notifications::Fanout.new
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

module AetherObservatory
RSpec.describe ObserverBase do
after(:each) { teardown }

describe "#process" do
it "processes a single event" do
# Given
Expand All @@ -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
Expand All @@ -40,6 +41,9 @@ module AetherObservatory

# Then
expect(observer.returned_payload.message).to eq("message one")

# Teardown
observer.stop
end
end

Expand All @@ -56,6 +60,9 @@ module AetherObservatory

# Then
expect(observer.returned_payload).to eq(nil)

# Teardown
observer.stop
end
end

Expand All @@ -72,6 +79,9 @@ module AetherObservatory

# Then
expect(observer.returned_payload.message).to eq("message")

# Teardown
observer.stop
end
end

Expand Down Expand Up @@ -104,10 +114,5 @@ def process
end
)
end

def teardown
ActiveSupport::Notifications.notifier =
ActiveSupport::Notifications::Fanout.new
end
end
end

0 comments on commit bd9fa17

Please sign in to comment.