lib/stubs/aws_stubs.rb in cloud_powers-0.2.7.14 vs lib/stubs/aws_stubs.rb in cloud_powers-0.2.7.15
- old
+ new
@@ -246,10 +246,21 @@
# Notes
# * defaults can't be overriden or don't have good support for
# for it yet but you can use this hash as a guide
# for your own custom configuration
def self.queue_stub(opts = {})
+ msg_body = if opts[:body]
+ if opts[:body].kind_of? Hash
+ opts[:body] = opts[:body].to_json
+ elsif JSON.parse(opts[:body])
+ begin
+ opts[:body]
+ rescue JSON::ParserError
+ {foo: 'bar'}.to_json
+ end
+ end
+ end
{
stub_responses: {
create_queue: {
queue_url: "https://sqs.us-west-2.amazonaws.com/12345678/#{opts[:name] || 'testQueue'}"
},
@@ -271,10 +282,10 @@
"ApproximateFirstReceiveTimestamp" => "1442428276921",
"ApproximateReceiveCount" => "5",
"SenderId" => "AIDAIAZKMSNQ7TEXAMPLE",
"SentTimestamp" => "1442428276921"
},
- body: "{\"foo\":\"bar\"}",
+ body: msg_body || "{\"foo\":\"bar\"}",
md5_of_body: "51b0a325...39163aa0",
md5_of_message_attributes: "00484c68...59e48f06",
message_attributes: {
"City" => {
data_type: "String",