Sha256: bedff40dabb6f2e55d356710f9437a282bbbdaec27e279dd35d0c95a7bb5ee88

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

RSpec.describe ExpressPigeon::Messages do
  let(:auth_key) { ENV['EXPRESS_PIGEON_AUTH_KEY'] }
  let(:client) { ExpressPigeon::Messages.new(auth_key) }
  let(:test_template_id) { Integer(ENV['TEST_TEMPLATE_ID']) }

  it 'sends a transactional email and gets a status report' do
    response = client.send(
      test_template_id,
      to: 'mike+to@just3ws.com',
      from: 'mike+from@just3ws',
      reply_to: 'mike+reply_to@just3ws.com',
      subject: 'Test sending EP transactional emails',
      merge_fields: { 'test_merge_field' => 'sending transactional email via EP' })

    expect(response['code']).to eq(200)
    expect(response['message']).to eq('email queued')
    message_id = response['id']
    expect(message_id).to be_a(Fixnum)

    # NOTE: Check the Inbox you configured for you Sandbox account to see the
    #       actual email as it was sent.

    # cheating in specs and piggy-backing to test the status[es] requests

    response = client.status(message_id)
    expect(response.code).to eq(200)
    report = response.select { |report| report['id'] == message_id }
    expect(report.length).to eq(1)
    expect(report.first['id']).to eq(message_id)

    response = client.statuses(from_id: message_id - 1)
    expect(response.code).to eq(200)
    report = response.select { |report| report['id'] == message_id }
    expect(report.length).to eq(1)
    expect(report.first['id']).to eq(message_id)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
express_pigeon-2.4.1 spec/lib/express_pigeon/messages_spec.rb
express_pigeon-2.4.0 spec/lib/express_pigeon/messages_spec.rb