Sha256: c1fe3543c9bb3de7e4a8855a5cd2a8b6ba931cd420572d2bc6095cf183bbba89

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module QueueBus
  describe Rider do
    it 'should call execute' do
      expect(QueueBus).to receive(:dispatcher_execute)
      Rider.perform('bus_rider_app_key' => 'app', 'bus_rider_sub_key' => 'sub', 'ok' => true, 'bus_event_type' => 'event_name')
    end

    it 'should change the value' do
      QueueBus.dispatch('r1') do
        subscribe 'event_name' do |attributes|
          Runner1.run(attributes)
        end
      end
      expect(Runner1.value).to eq(0)
      Rider.perform('bus_locale' => 'en', 'bus_timezone' => 'PST', 'bus_rider_app_key' => 'r1', 'bus_rider_sub_key' => 'event_name', 'ok' => true, 'bus_event_type' => 'event_name')
      Rider.perform('bus_rider_app_key' => 'other', 'bus_rider_sub_key' => 'event_name', 'ok' => true, 'bus_event_type' => 'event_name')
      expect(Runner1.value).to eq(1)
    end

    it 'should set the timezone and locale if present' do
      QueueBus.dispatch('r1') do
        subscribe 'event_name' do |attributes|
          Runner1.run(attributes)
        end
      end

      expect(defined?(I18n)).to be_nil
      expect(Time.respond_to?(:zone)).to eq(false)

      stub_const('I18n', Class.new)
      expect(I18n).to receive(:locale=).with('en')
      expect(Time).to receive(:zone=).with('PST')

      Rider.perform('bus_locale' => 'en', 'bus_timezone' => 'PST', 'bus_rider_app_key' => 'r1', 'bus_rider_sub_key' => 'event_name', 'ok' => true, 'bus_event_type' => 'event_name')
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
queue-bus-0.13.3 spec/rider_spec.rb
queue-bus-0.13.2 spec/rider_spec.rb
queue-bus-0.13.1 spec/rider_spec.rb
queue-bus-0.13.0 spec/rider_spec.rb
queue-bus-0.12.0 spec/rider_spec.rb
queue-bus-0.11.0 spec/rider_spec.rb
queue-bus-0.10.0 spec/rider_spec.rb
queue-bus-0.9.1 spec/rider_spec.rb
sidekiq-bus-0.9.0 spec/rider_spec.rb
sidekiq-bus-0.8.2 spec/rider_spec.rb