Sha256: cda7e204db57b5f52f8ce60113d5a9c0f4ccc9dc0a1fb91d2c69058342e14ecd

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

describe 'X-SMTPAPI compatibility' do
  describe "xsmtpapi for bulk" do
    # This should guarantee the expected behavior for the following api:
    #   http://sendgrid.com/docs/API_Reference/SMTP_API/unique_arguments.html
    context "generates expected xsmtpapi for #post!" do
      let(:envelope_bag) { build(:empty_envelope_bag)}
      let(:envelope) { build(:envelope_multi, xsmtpapi: { "sub" => { "-email-id-" => ["314159","271828"] }, "unique_args" => { "email_id" => "-email-id-"} }) }
      let(:expectated_hash) { {"sub"=>{"-email-id-"=>["314159", "271828"], "*|NAME|*"=>["Mail Cannon", "Lucas Martins", "Contact"], "*|EMAIL|*"=>["mailcannon@railsnapraia.com", "lucasmartins@railsnapraia.com", "contact@railsonthebeach.com"]}, "unique_args"=>{"email_id"=>"-email-id-", "envelope_id"=>envelope.id, "envelope_bag_id"=>envelope_bag.id}, "to"=>["mailcannon@railsnapraia.com", "lucasmartins@railsnapraia.com", "contact@railsonthebeach.com"]} }

      it "returns true" do
        envelope_bag.save
        envelope_bag.envelopes << envelope
        VCR.use_cassette('mailcannon_adapter_sendgrid_send_bulk') do
          Sidekiq::Testing.inline! do
            envelope.post!
          end
        end
        envelope.save
        envelope.reload # content is changed inside the Adapter module
        expect(envelope.xsmtpapi).to eq(expectated_hash)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailcannon-0.1.1 spec/integration/xsmtpapi_spec.rb
mailcannon-0.1.0.pre.1 spec/integration/xsmtpapi_spec.rb
mailcannon-0.0.8.pre.1 spec/integration/xsmtpapi_spec.rb