spec/spec_helper.rb in sqewer-3.0.0 vs spec/spec_helper.rb in sqewer-3.0.1

- old
+ new

@@ -1,38 +1,19 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' -require 'simplecov' - +require 'rspec/wait' require 'dotenv' +require 'aws-sdk' +require 'simplecov' Dotenv.load -require 'aws-sdk' - SimpleCov.start require 'sqewer' -module Polling - # Call the given block every N seconds, and return once the - # block returns a truthy value. If it still did not return - # the value after fail_after, fail the spec. - def poll(every: 0.5, fail_after:, &check_block) - started_polling = Time.now - loop do - return if check_block.call - sleep(every) - if (Time.now - started_polling) > fail_after - fail "Waited for #{fail_after} seconds for the operation to complete but it didnt" - end - end - end -end - RSpec.configure do |config| config.order = 'random' - config.include Polling - config.around :each do | example | if example.metadata[:sqs] queue_name = 'conveyor-belt-test-queue-%s' % SecureRandom.hex(6) client = Aws::SQS::Client.new resp = client.create_queue(queue_name: queue_name)