Sha256: c7e1c0c155f02be54f28c6c85a3a5bab2679e53ea1ec7a0d4a27e11ff8727130

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'
require 'mailstro/test'

describe Mailstro::Test do
  describe '.enable' do
    before do
      Mailstro::Test.enable
    end

    after do
      Mailstro::Test.disable
    end

    it "doesn't send deliveries when enabled" do
      Mailstro::Delivery.should_not_receive(:deliver).with(:template_name, 'a@a.com', {})

      Mailstro.deliver(:template_name, 'a@a.com')
    end

    it "adds the delivery to the deliveries array" do
      Mailstro.deliver(:template_name, 'a@a.com')

      Mailstro::Test.deliveries.should_not be_empty
    end
  end

  describe '.disable' do
    it 'restores the previous behaviour of .deliver' do
      Mailstro::Test.enable
      Mailstro::Test.disable
      Mailstro::Delivery.should_receive(:deliver).with(:template_name, 'a@a.com', {})

      Mailstro.deliver(:template_name, 'a@a.com')
    end
  end

  describe '.clear_deliveries' do
    before do
      Mailstro::Test.enable

      Mailstro.deliver(:template_name, 'a@a.com')
    end

    after do
      Mailstro::Test.disable
    end

    it 'empties out the .deliveries array' do
      Mailstro::Test.deliveries.should_not be_empty
      Mailstro::Test.clear_deliveries

      Mailstro::Test.deliveries.should be_empty
    end
  end

  describe '.has_delivered?' do
    before do
      Mailstro::Test.enable
    end

    after do
      Mailstro::Test.disable
    end

    it 'returns true if there was a delivery matching the template name give' do
      Mailstro.deliver(:template_name, 'a@a.com')

      Mailstro.has_delivered?(:template => :template_name)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mailstro-0.0.6 spec/mailstro/test_spec.rb
mailstro-0.0.5 spec/mailstro/test_spec.rb
mailstro-0.0.4 spec/mailstro/test_spec.rb
mailstro-0.0.3 spec/mailstro/test_spec.rb