Module: JetstreamBridge::TestHelpers::Fixtures
- Defined in:
- lib/jetstream_bridge/test_helpers/fixtures.rb
Overview
Common fixtures for quickly building events in specs.
Class Method Summary collapse
-
.event(event_type:, payload: {}, **attrs) ⇒ Object
Build a generic event with custom attributes.
-
.sample_events(count = 3, type: 'test.event') ⇒ Object
Build multiple sample events.
-
.user_created_event(attrs = {}) ⇒ Object
Build a user.created event.
Class Method Details
.event(event_type:, payload: {}, **attrs) ⇒ Object
Build a generic event with custom attributes
32 33 34 35 36 37 38 |
# File 'lib/jetstream_bridge/test_helpers/fixtures.rb', line 32 def event(event_type:, payload: {}, **attrs) JetstreamBridge::TestHelpers.build_jetstream_event( event_type: event_type, payload: payload, **attrs ) end |
.sample_events(count = 3, type: 'test.event') ⇒ Object
Build multiple sample events
22 23 24 25 26 27 28 29 |
# File 'lib/jetstream_bridge/test_helpers/fixtures.rb', line 22 def sample_events(count = 3, type: 'test.event') Array.new(count) do |i| JetstreamBridge::TestHelpers.build_jetstream_event( event_type: type, payload: { id: i + 1, sequence: i } ) end end |
.user_created_event(attrs = {}) ⇒ Object
Build a user.created event
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jetstream_bridge/test_helpers/fixtures.rb', line 10 def user_created_event(attrs = {}) JetstreamBridge::TestHelpers.build_jetstream_event( event_type: 'user.created', payload: { id: attrs[:id] || 1, email: attrs[:email] || '[email protected]', name: attrs[:name] || 'Test User' }.merge(attrs[:payload] || {}) ) end |