Class: PactWaterdropClient

Inherits:
Object
  • Object
show all
Defined in:
lib/sbmt/pact/rspec/support/waterdrop/pact_waterdrop_client.rb

Defined Under Namespace

Classes: Report

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/sbmt/pact/rspec/support/waterdrop/pact_waterdrop_client.rb', line 4

def message
  @message
end

Instance Method Details

#produce_async(message) ⇒ Object



8
9
10
# File 'lib/sbmt/pact/rspec/support/waterdrop/pact_waterdrop_client.rb', line 8

def produce_async(message)
  @message = message
end

#produce_sync(message) ⇒ Object



12
13
14
15
# File 'lib/sbmt/pact/rspec/support/waterdrop/pact_waterdrop_client.rb', line 12

def produce_sync(message)
  @message = message
  Report.new(partition: 0, offset: 0, topic_name: message[:topic])
end

#to_pact(content_type: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/sbmt/pact/rspec/support/waterdrop/pact_waterdrop_client.rb', line 17

def to_pact(content_type: nil)
  payload = message[:payload]
   = {
    key: message[:key],
    topic: message[:topic],
    content_type: content_type
  }.merge(message[:headers] || {})

  [payload, ]
end