Sha256: 23c615dbc108a02ccc8f8227baefd70f6ed1e7f67f5d57bd413d9dd314bce5ef

Contents?: true

Size: 1.93 KB

Versions: 23

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

module QueueBus
  module Adapters
    class TestOne

    end
  end
end

describe "QueueBus config" do
  it "should set the default app key" do
    QueueBus.default_app_key.should == nil

    QueueBus.default_app_key = "my_app"
    QueueBus.default_app_key.should == "my_app"

    QueueBus.default_app_key = "something here"
    QueueBus.default_app_key.should == "something_here"
  end

  it "should set the default queue" do
    QueueBus.default_queue.should == nil

    QueueBus.default_queue = "my_queue"
    QueueBus.default_queue.should == "my_queue"
  end

  it "should set the local mode" do
    QueueBus.local_mode.should == nil
    QueueBus.local_mode = :standalone
    QueueBus.local_mode.should == :standalone
  end

  it "should set the hostname" do
    QueueBus.hostname.should_not == nil
    QueueBus.hostname = "whatever"
    QueueBus.hostname.should == "whatever"
  end

  it "should set before_publish callback" do
    QueueBus.before_publish = lambda {|attributes| 42 }
    QueueBus.before_publish_callback({}).should == 42
  end


  it "should use the default Redis connection" do
    QueueBus.redis { |redis| redis }.should_not eq(nil)
  end

  it "should default to given adapter" do
    QueueBus.adapter.is_a?(adapter_under_test_class).should == true

    # and should raise if already set
    lambda {
      QueueBus.adapter = :data
    }.should raise_error
  end

  context "with a fresh load" do
    before(:each) do
      QueueBus.send(:reset)
    end

    it "should be able to be set to resque" do
      QueueBus.adapter = adapter_under_test_symbol
      QueueBus.adapter.is_a?(adapter_under_test_class).should == true

      # and should raise if already set
      lambda {
        QueueBus.adapter = :data
      }.should raise_error
    end

    it "should be able to be set to something else" do

      QueueBus.adapter = :test_one
      QueueBus.adapter.is_a?(QueueBus::Adapters::TestOne).should == true
    end
  end


end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
resque-bus-0.7.0 spec/config_spec.rb
resque-bus-0.6.1 spec/config_spec.rb
resque-bus-0.6.0 spec/config_spec.rb
resque-bus-0.5.12 spec/config_spec.rb
queue-bus-0.5.9 spec/config_spec.rb
resque-bus-0.5.11 spec/config_spec.rb
queue-bus-0.5.8 spec/config_spec.rb
resque-bus-0.5.10 spec/config_spec.rb
queue-bus-0.5.7 spec/config_spec.rb
sidekiq-bus-0.5.5 spec/config_spec.rb
resque-bus-0.5.9 spec/config_spec.rb
sidekiq-bus-0.5.4 spec/config_spec.rb
resque-bus-0.5.8 spec/config_spec.rb
queue-bus-0.5.6 spec/config_spec.rb
resque-bus-0.5.7 spec/config_spec.rb
queue-bus-0.5.5 spec/config_spec.rb
sidekiq-bus-0.5.3 spec/config_spec.rb
queue-bus-0.5.4 spec/config_spec.rb
queue-bus-0.5.3 spec/config_spec.rb
sidekiq-bus-0.5.2 spec/config_spec.rb