Class: Karafka::Testing::RSpec::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/testing/rspec/proxy.rb

Overview

Proxy object for a nicer karafka. API within RSpec None other should be used by the end users

Instance Method Summary collapse

Constructor Details

#initialize(rspec_example) ⇒ Proxy

Returns a new instance of Proxy.

Parameters:

  • rspec_example (RSpec::ExampleGroups)

    rspec context



10
11
12
# File 'lib/karafka/testing/rspec/proxy.rb', line 10

def initialize(rspec_example)
  @rspec_example = rspec_example
end

Instance Method Details

#consumer_for(*args) ⇒ Object

Parameters:

  • args

    Anything that the #_karafka_consumer_for accepts



15
16
17
# File 'lib/karafka/testing/rspec/proxy.rb', line 15

def consumer_for(*args)
  @rspec_example._karafka_consumer_for(*args)
end

#consumer_messagesArray<Karafka::Messages::Message>

Returns array of messages that will be used to construct the final consumer messages batch.

Returns:

  • (Array<Karafka::Messages::Message>)

    array of messages that will be used to construct the final consumer messages batch



31
32
33
# File 'lib/karafka/testing/rspec/proxy.rb', line 31

def consumer_messages
  @rspec_example._karafka_consumer_messages
end

#produce(*args) ⇒ Object

Parameters:

  • args

    Anything that #_karafka_produce accepts



20
21
22
# File 'lib/karafka/testing/rspec/proxy.rb', line 20

def produce(*args)
  @rspec_example._karafka_produce(*args)
end

#produced_messagesArray<Hash>

Returns messages produced via Karafka#producer.

Returns:

  • (Array<Hash>)

    messages produced via Karafka#producer



25
26
27
# File 'lib/karafka/testing/rspec/proxy.rb', line 25

def produced_messages
  @rspec_example._karafka_produced_messages
end