Sha256: 2646de1be155c3dd6a9a5c67f9d155a99fb6f66b12685da3e3f1eb8e449342e3

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'timecop'
require 'queue-bus'
require 'adapter/support'

reset_test_adapter

module QueueBus
  class Runner
    def self.value
      @value ||= 0
    end

    class << self
      attr_reader :attributes
    end

    def self.run(attrs)
      @value ||= 0
      @value += 1
      @attributes = attrs
    end

    def self.reset
      @value = nil
      @attributes = nil
    end
  end

  class Runner1 < Runner
  end

  class Runner2 < Runner
  end
end

def test_sub(event_name, queue = 'default')
  matcher = { 'bus_event_type' => event_name }
  QueueBus::Subscription.new(queue, event_name, '::QueueBus::Rider', matcher, nil)
end

def test_list(*args)
  out = QueueBus::SubscriptionList.new
  args.each do |sub|
    out.add(sub)
  end
  out
end

RSpec.configure do |config|
  config.mock_with :rspec do |c|
    c.syntax = :expect
  end

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  config.before(:each) do
    reset_test_adapter
  end

  config.after(:each) do
    begin
      QueueBus.redis(&:flushall)
    rescue RuntimeError # rubocop:disable Lint/HandleExceptions
      # We raise if redis isn't there.
    end
    QueueBus.send(:reset)
    QueueBus::Runner1.reset
    QueueBus::Runner2.reset
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
queue-bus-0.13.3 spec/spec_helper.rb
queue-bus-0.13.2 spec/spec_helper.rb
queue-bus-0.13.1 spec/spec_helper.rb
queue-bus-0.13.0 spec/spec_helper.rb
queue-bus-0.12.0 spec/spec_helper.rb
queue-bus-0.11.0 spec/spec_helper.rb
queue-bus-0.10.0 spec/spec_helper.rb
queue-bus-0.9.1 spec/spec_helper.rb