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) ⇒ 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) ⇒ 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, **) Rimless.avro_decode(data, **) end |
#capture_kafka_messages { ... } ⇒ Array<Hash{Symbol => Mixed}>
Capture all Apache Kafka messages of the given block.
50 51 52 |
# File 'lib/rimless/rspec/helpers.rb', line 50 def (&) Rimless::RSpec::Matchers::HaveSentKafkaMessage.new(nil).capture(&) 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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rimless/rspec/helpers.rb', line 29 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 |