Sha256: edef066f45111c44fbdad66ff266863fdd4476a041d6b9875391ab4c8c16b40b
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
SOURCE_QUEUE_NAME = "TestSourceQueue" DLQ_QUEUE_NAME = "TestSourceQueueDLQ" RSpec.shared_context "sqs_setup", :sqs do require 'support/rails_app' require 'support/fake_sqs' Capybara.app = RailsApp let(:sqs) { Aws::SQS::Client.new(region: "us-east-1", credentials: Aws::Credentials.new("fake", "fake")) } let(:source_queue_url) { sqs.get_queue_url(queue_name: SOURCE_QUEUE_NAME).queue_url } let(:dlq_queue_url) { sqs.get_queue_url(queue_name: DLQ_QUEUE_NAME).queue_url } before do sqs.config.endpoint = $fake_sqs.uri [SOURCE_QUEUE_NAME, DLQ_QUEUE_NAME].each{|queue_name| sqs.create_queue(queue_name: queue_name)} dlq_arn = sqs.get_queue_attributes(queue_url: dlq_queue_url).attributes.fetch("QueueArn") #Set DLQ sqs.set_queue_attributes( queue_url: source_queue_url, attributes: { "RedrivePolicy" => "{\"deadLetterTargetArn\":\"#{dlq_arn}\",\"maxReceiveCount\":10}" } ) SqsWeb.options[:queues] = [SOURCE_QUEUE_NAME, DLQ_QUEUE_NAME] end def receive_messages(queue_url, options = {count: 1}) sqs.receive_message({ queue_url: queue_url, attribute_names: ["All"], message_attribute_names: ["All"], max_number_of_messages: options[:count], wait_time_seconds: 1, visibility_timeout: options[:visibility_timeout] }) end def default_messages generate_messages(source_queue_url, 5) + generate_messages(dlq_queue_url, 3) end def generate_messages(queue_url, count=1) messages = [] count.times do |time| messages << sqs.send_message(queue_url: queue_url, message_body: "Test_#{time}", message_attributes: {"foo_class"=> {string_value: "FooWorker", data_type: "String"}}) end messages end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sqs_web-0.0.2 | spec/support/shared_context.rb |