Sha256: cf215c5296c4b4afa75c38db028879a6f4a2fa6342d8d706ad858012d6182d27

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe Mail::Postmark do
  let(:message) do
    Mail.new do
      from    "sheldon@bigbangtheory.com"
      to      "lenard@bigbangtheory.com"
      subject "Hello!"
      body    "Hello Sheldon!"
    end
  end

  it "can be set as delivery_method" do
    message.delivery_method Mail::Postmark
  end

  it "wraps Postmark.send_through_postmark" do
    Postmark::ApiClient.any_instance.should_receive(:deliver_message).with(message)
    message.delivery_method Mail::Postmark
    message.deliver
  end

  it "returns self by default" do
    Postmark::ApiClient.any_instance.should_receive(:deliver_message).with(message)
    message.delivery_method Mail::Postmark
    message.deliver.should eq message
  end

  it "returns the actual response if :return_response setting is present" do
    Postmark::ApiClient.any_instance.should_receive(:deliver_message).with(message)
    message.delivery_method Mail::Postmark, :return_response => true
    message.deliver.should eq message
  end

  it "allows setting the api token" do
    message.delivery_method Mail::Postmark, :api_token => 'api-token'
    message.delivery_method.settings[:api_token].should == 'api-token'
  end

  it 'uses provided API token' do
    message.delivery_method Mail::Postmark, :api_token => 'api-token'
    Postmark::ApiClient.should_receive(:new).with('api-token', {}).and_return(double(:deliver_message => true))
    message.deliver
  end

  it 'uses API token provided as legacy api_key' do
    message.delivery_method Mail::Postmark, :api_key => 'api-token'
    Postmark::ApiClient.should_receive(:new).with('api-token', {}).and_return(double(:deliver_message => true))
    message.deliver
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
postmark-1.10.0 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.9.1 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.9.0 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.8.1 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.8.0 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.7.1 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.7.0 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.6.0 spec/unit/postmark/handlers/mail_spec.rb
postmark-1.5.0 spec/unit/postmark/handlers/mail_spec.rb