Sha256: 35f5ca9f2c2152c4f3691f0d95810bca7c90a26d3c4d60a68c52cec840683df0

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

#encoding: utf-8
require 'spec_helper'

describe Pousse::RedisDelivery do

  let :redis do
   Pousse::RedisDelivery.new {} 
  end

  describe '#deliver!' do

    let :redis_instance do
      redis_instance = stub()
      Redis.stub(new: redis_instance)
      redis_instance
    end

    let :mail do
      stub(
          to: 'everyone',
          body: 'alert("Générale !");'
        )
    end

    it 'publish to redis' do
      redis_instance
        .should_receive(:publish)
        .with('everyone',  'alert("Générale !");')
      redis.deliver!(mail)
    end

    it 'does not fail when redis can not connect' do
      redis_instance.should_receive :publish do
        raise Redis::CannotConnectError.new 'Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)'
      end
      expect{ redis.deliver!(mail) }.to_not raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pousse-0.0.2 spec/redis_delivery_spec.rb