Class: AwsSqsFauxClient
- Inherits:
-
Object
- Object
- AwsSqsFauxClient
- Defined in:
- lib/spec_support/aws_sqs_faux_client.rb
Overview
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #get_queue_url ⇒ Object
-
#initialize(queue_url: nil) ⇒ AwsSqsFauxClient
constructor
A new instance of AwsSqsFauxClient.
- #receive_message(arg_hash) ⇒ Object
- #send_message(arg_hash) ⇒ Object
- #send_message_batch(arg_hash) ⇒ Object
Constructor Details
#initialize(queue_url: nil) ⇒ AwsSqsFauxClient
Returns a new instance of AwsSqsFauxClient.
9 10 11 12 |
# File 'lib/spec_support/aws_sqs_faux_client.rb', line 9 def initialize(queue_url: nil) @queue_url = queue_url || 'https://sqs.us-west-2.amazonaws.com/5555555555/fake' @storage = {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
13 14 15 |
# File 'lib/spec_support/aws_sqs_faux_client.rb', line 13 def storage @storage end |
Instance Method Details
#get_queue_url ⇒ Object
33 34 35 |
# File 'lib/spec_support/aws_sqs_faux_client.rb', line 33 def get_queue_url(*) OpenStruct.new(queue_url: @queue_url) end |
#receive_message(arg_hash) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/spec_support/aws_sqs_faux_client.rb', line 25 def (arg_hash) output = [] args_hash[:mx_number_of_messages].times do value = @storage[arg_hash[:queue_url]]&.pop output << value if value end end |
#send_message(arg_hash) ⇒ Object
15 16 17 18 |
# File 'lib/spec_support/aws_sqs_faux_client.rb', line 15 def (arg_hash) @storage[arg_hash[:queue_url]] ||= [] @storage[arg_hash[:queue_url]] << arg_hash[:message_body] end |
#send_message_batch(arg_hash) ⇒ Object
20 21 22 23 |
# File 'lib/spec_support/aws_sqs_faux_client.rb', line 20 def (arg_hash) @storage[arg_hash[:queue_url]] ||= [] @storage[arg_hash[:queue_url]] += arg_hash[:entries] end |