Module: Rimless::RSpec::Helpers
- Defined in:
- lib/rimless/rspec/helpers.rb
Overview
A collection of Rimless/RSpec helpers.
Instance Method Summary collapse
-
#avro_parse(data, **opts) ⇒ Hash{String => Mixed}
A simple helper to parse a blob of Apache Avro data.
-
#capture_kafka_messages { ... } ⇒ Array<Hash{Symbol => Mixed}>
Capture all Apache Kafka messages of the given block.
-
#kafka_message(topic: nil, headers: {}, **payload) ⇒ OpenStruct
A simple helper to fake a deserialized Apache Kafka message for consuming.
Instance Method Details
#avro_parse(data, **opts) ⇒ Hash{String => Mixed}
A simple helper to parse a blob of Apache Avro data.
13 14 15 |
# File 'lib/rimless/rspec/helpers.rb', line 13 def avro_parse(data, **opts) Rimless.avro_decode(data, **opts) end |
#capture_kafka_messages { ... } ⇒ Array<Hash{Symbol => Mixed}>
Capture all Apache Kafka messages of the given block.
49 50 51 |
# File 'lib/rimless/rspec/helpers.rb', line 49 def (&block) Rimless::RSpec::Matchers::HaveSentKafkaMessage.new(nil).capture(&block) end |
#kafka_message(topic: nil, headers: {}, **payload) ⇒ OpenStruct
A simple helper to fake a deserialized Apache Kafka message for consuming.
rubocop:disable Metrics/MethodLength because of the various properties rubocop:disable Style/OpenStructUse because existing specs may rely
on this data type
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rimless/rspec/helpers.rb', line 28 def (topic: nil, headers: {}, **payload) OpenStruct.new( topic: Rimless.topic(topic), headers: headers, payload: payload, is_control_record: false, key: nil, offset: 206, partition: 0, create_time: Time.current, receive_time: Time.current, deserialized: true ) end |