Sha256: 5d97715a052e0a1b97265f311353415bd77913cf303bbe497649666e579063ff

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

require "spec_helper"

describe MailCannon::EnvelopeBag do
  describe "#post!" do
    context "when it has no Envelopes" do
      let(:envelope_bag) { build(:empty_envelope_bag) }
      it "does not raise error" do
        expect{envelope_bag.post!}.not_to raise_error
      end
      it "returns false" do
        expect(envelope_bag.post!).to be_false
      end
    end
    context "when it has Envelopes" do
      let(:envelope_bag) { build(:filled_envelope_bag) }
      it "does not raise error" do
        expect{envelope_bag.post!}.not_to raise_error
      end
      it "returns true" do
        expect(envelope_bag.post!).to be_true
      end
    end
    context "when it has Envelopes (isolating Bag)" do
      let(:envelope_bag) { MailCannon::EnvelopeBag.new }
      it "posts Envelopes in the bag" do
        envelope_bag.envelopes.push build(:envelope)
        envelope_bag.envelopes.push build(:envelope_multi)
        expect(envelope_bag.envelopes.size).to eq(2)
        # Rspec can't do 'any_instance.should_receive' twice.
        envelope_bag.envelopes.each do |envelope|
          expect(envelope).to receive(:post!)
        end
        envelope_bag.post!
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mailcannon-0.1.1 spec/mailcannon/envelope_bag_spec.rb
mailcannon-0.1.0.pre.1 spec/mailcannon/envelope_bag_spec.rb
mailcannon-0.0.8.pre.1 spec/mailcannon/envelope_bag_spec.rb
mailcannon-0.0.8 spec/mailcannon/envelope_bag_spec.rb
mailcannon-0.0.6 spec/mailcannon/envelope_bag_spec.rb
mailcannon-0.0.5 spec/mailcannon/envelope_bag_spec.rb