Sha256: fc1fe7963131d813f72dabacad4dcb12129b428c46879a784bc9f58165c631cc

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe Waffle do
  describe ".configure" do
    after do
      Waffle.reset_config!
    end

    context "when no block supplied" do
      let(:config_hash){{
        'development' => {
          'transport' => 'redis',
          'url' => 'redis://localhost:port/0',
          'encoder' => 'json'
        }
      }}

      before do
        YAML.stub(:load_file => config_hash)
        File.stub(:exists? => true)
        Waffle::Config.stub(:environment => 'development')
        Waffle.configure
      end

      specify{Waffle.config.should == Waffle::Config}
      specify{Waffle.config.transport.should == 'redis'}
      specify{Waffle.config.encoder.should == 'json'}
      specify{Waffle.config.connection_attempt_timeout.should == 30}
      specify{Waffle.config.url.should == 'redis://localhost:port/0'}
    end

    context "when a block is supplied" do
      before do
        Waffle.configure do
          default do |config|
            config.transport = 'redis'
          end
        end
      end

      after do
        Waffle.configure do |config|
          config.transport = nil
        end
      end

      specify{Waffle.config.transport.should == 'redis'}
    end
  end
  
  context do
    before do
      Waffle.configure
      Waffle::Config.stub(:queues => {:default => transport})
    end

    let(:transport){mock(:transport)}

    describe '#publish' do
      let(:args){['flow', 'message']}

      before do
        transport.should_receive(:publish).with(*args)
      end

      specify{Waffle.publish(*args)}
    end

    describe '#subscribe' do
      before do
        transport.should_receive(:subscribe).with('flow')
      end

      specify{Waffle.subscribe('flow')}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
waffle-0.5.1 spec/waffle_spec.rb
waffle-0.5.0 spec/waffle_spec.rb