Sha256: a8e38919afa36917863627b89f60a9cc61972c9e5d47c781b8854e0d4568a677

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'
require 'mailstro/test_strategy'

describe Mailstro::TestStrategy do
  before do
    Mailstro::TestStrategy.enable
  end

  describe '.enable' do
    it "doesn't send anything when enabled" do
      Mailstro::Delivery.should_not_receive(:deliver)
      Mailstro::ListDelivery.should_not_receive(:deliver)
      Mailstro::ListSubscribe.should_not_receive(:deliver)
      Mailstro::ListUnsubscribe.should_not_receive(:deliver)

      Mailstro.deliver(
        :to            => 'a@a.com',
        :template_name => :welcome
      )

      Mailstro.subscribe('a@a.com', :watchers, 12)

      Mailstro.deliver(
        :to            => [:watchers, 12],
        :template_name => :welcome
      )

      Mailstro.unsubscribe('a@a.com', :watchers, 12)
    end
  end

  describe '.clear' do
    before do
      Mailstro.deliver(
        :to            => 'a@a.com',
        :template_name => :welcome
      )
    end

    it 'empties out the .deliveries array' do
      Mailstro::TestStrategy.deliveries.should_not be_empty
      Mailstro::TestStrategy.clear

      Mailstro::TestStrategy.deliveries.should be_empty
    end
  end

  describe '.has_delivered?' do
    it 'keeps a record of deliveries' do
      Mailstro.deliver(
        :to            => 'a@a.com',
        :template_name => :welcome
      )

      Mailstro.should have_delivered(:welcome)
    end

    it 'keeps a record of list deliveries' do
      Mailstro.deliver(
        :to            => [:list_type, 10],
        :template_name => :welcome
      )

      Mailstro.should have_delivered(:welcome)
    end
  end

  describe '.has_subsribed?' do
    it 'keeps a record of subscribes' do
      Mailstro.subscribe('a@a.com', :watchers, 2)

      Mailstro.should have_subscribed('a@a.com', :watchers, 2)
    end
  end

  describe '.has_unsubsribed?' do
    it 'keeps a record of unsubscribes' do
      Mailstro.unsubscribe('a@a.com', :watchers, 2)

      Mailstro.should have_unsubscribed('a@a.com', :watchers, 2)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mailstro-0.0.7 spec/mailstro/test_strategy_spec.rb