Sha256: 20b3e5ce1b93b6fbd8960702b1cae6208de4b79941022d377ada4b3b37f070ec

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'bundler/setup'
Bundler.setup

require 'pry-byebug'
require 'celluloid'
require 'shoryuken'

options_file = File.join(File.expand_path('../..', __FILE__), 'shoryuken.yml')

$options = {}

if File.exists? options_file
  $options = YAML.load(File.read(options_file)).deep_symbolize_keys

  AWS.config $options[:aws]
end

Shoryuken.logger.level = Logger::UNKNOWN
Celluloid.logger.level = Logger::UNKNOWN

class TestWorker
  include Shoryuken::Worker

  shoryuken_options queue: 'default'

  def perform(sqs_msg, body); end
end

RSpec.configure do |config|
  config.filter_run_excluding slow: true unless ENV['SPEC_ALL']

  config.before do
    # remove doubles, preventing:
    # Double "Queue" was originally created in one example but has leaked into another example and can no longer be used.
    # rspec-mocks' doubles are designed to only last for one example, and you need to create a new one in each example you wish to use it for.
    Shoryuken::Client.class_variable_set :@@queues, {}
    Shoryuken::Client.class_variable_set :@@visibility_timeouts, {}

    Shoryuken.options.clear
    Shoryuken.options.merge!($options)

    Shoryuken.queues.clear
    Shoryuken.queues << 'shoryuken'
    Shoryuken.options[:concurrency] = 1
    Shoryuken.options[:delay]       = 1
    Shoryuken.options[:timeout]     = 1

    Shoryuken.options[:aws] = {}

    TestWorker.get_shoryuken_options.clear
    TestWorker.get_shoryuken_options['queue'] = 'default'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoryuken-0.0.3 spec/spec_helper.rb