Sha256: 5323075099412ec47cb6bcba6d126e0a9b2d8d0eb28d6724a5948e48b4365c6c

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 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: stub(decoded: '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

2 entries across 2 versions & 1 rubygems

Version Path
pousse-0.0.4 spec/pousse/redis_delivery_spec.rb
pousse-0.0.3 spec/pousse/redis_delivery_spec.rb