Sha256: c6a166ceeeaadffa3a3d0c0a9504b93e400215780a217ae7e230114594dd5f26

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Sneakers::Configuration do

  it 'should assign a default value for :amqp' do
    with_env('RABBITMQ_URL', nil) do
      config = Sneakers::Configuration.new
      config[:amqp].must_equal 'amqp://guest:guest@localhost:5672'
    end
  end

  it 'should assign a default value for :vhost' do
    with_env('RABBITMQ_URL', nil) do
      config = Sneakers::Configuration.new
      config[:vhost].must_equal '/'
    end
  end

  it 'should read the value for amqp from RABBITMQ_URL' do
    url = 'amqp://foo:bar@localhost:5672'
    with_env('RABBITMQ_URL', url) do
      config = Sneakers::Configuration.new
      config[:amqp].must_equal url
    end
  end

  it 'should read the value for vhost from RABBITMQ_URL' do
    url = 'amqp://foo:bar@localhost:5672/foobarvhost'
    with_env('RABBITMQ_URL', url) do
      config = Sneakers::Configuration.new
      config[:vhost].must_equal 'foobarvhost'
    end
  end

  def with_env(key, value)
    old_value = ENV[key]
    ENV[key] = value
    yield
  ensure
    ENV[key] = old_value
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sneakers-1.0.2 spec/sneakers/configuration_spec.rb
sneakers-1.0.1 spec/sneakers/configuration_spec.rb
sneakers-1.0.0 spec/sneakers/configuration_spec.rb