diff --git a/spec/integration/api_client_hashes_spec.rb b/spec/integration/api_client_hashes_spec.rb index d154992..c9a0722 100644 --- a/spec/integration/api_client_hashes_spec.rb +++ b/spec/integration/api_client_hashes_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' describe "Sending messages as Ruby hashes with Postmark::ApiClient" do - let(:message_id_format) { /<.+@.+>/ } - let(:postmark_message_id_format) { /\w{8}\-\w{4}-\w{4}-\w{4}-\w{12}/ } - let(:api_client) { Postmark::ApiClient.new('POSTMARK_API_TEST', :http_open_timeout => 15, :http_read_timeout => 15) } + let(:message_id_format) {/<.+@.+>/} + let(:postmark_message_id_format) {/\w{8}\-\w{4}-\w{4}-\w{4}-\w{12}/} + let(:api_client) {Postmark::ApiClient.new('POSTMARK_API_TEST', :http_open_timeout => 15, :http_read_timeout => 15)} let(:message) { { - :from => "sender@postmarkapp.com", - :to => "recipient@postmarkapp.com", - :subject => "Mail::Message object", - :text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \ + :from => "sender@postmarkapp.com", + :to => "recipient@postmarkapp.com", + :subject => "Mail::Message object", + :text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \ "sed do eiusmod tempor incididunt ut labore et dolore " \ "magna aliqua." } @@ -18,8 +18,8 @@ let(:message_with_no_body) { { - :from => "sender@postmarkapp.com", - :to => "recipient@postmarkapp.com", + :from => "sender@postmarkapp.com", + :to => "recipient@postmarkapp.com", } } @@ -29,66 +29,60 @@ end } - let(:message_with_invalid_to) { - { - :from => "sender@postmarkapp.com", - :to => "@postmarkapp.com" - } - } + let(:message_with_invalid_to) {{:from => "sender@postmarkapp.com", :to => "@postmarkapp.com"}} + let(:valid_messages) {[message, message.dup]} + let(:partially_valid_messages) {[message, message.dup, message_with_no_body]} + let(:invalid_messages) {[message_with_no_body, message_with_no_body.dup]} - let(:valid_messages) { [message, message.dup] } - let(:partially_valid_messages) { [message, message.dup, message_with_no_body] } - let(:invalid_messages) { [message_with_no_body, message_with_no_body.dup] } - - context "message by message" do - it 'delivers a plain text message' do + context "single message" do + it 'plain text message' do expect(api_client.deliver(message)).to have_key(:message_id) end - it 'updates a message object with Message-ID' do - expect(api_client.deliver(message)[:message_id]).to be =~ postmark_message_id_format + it 'message with attachment' do + expect(api_client.deliver(message_with_attachment)).to have_key(:message_id) end - it 'returns full Postmark response' do - expect(api_client.deliver(message)).to be_a Hash + it 'response Message-ID' do + expect(api_client.deliver(message)[:message_id]).to be =~ postmark_message_id_format end - it 'delivers a message with attachment' do - expect(api_client.deliver(message_with_attachment)).to have_key(:message_id) + it 'response is Hash' do + expect(api_client.deliver(message)).to be_a Hash end it 'fails to deliver a message without body' do - expect { api_client.deliver(message_with_no_body) }.to raise_error(Postmark::InvalidMessageError) + expect {api_client.deliver(message_with_no_body)}.to raise_error(Postmark::InvalidMessageError) end it 'fails to deliver a message with invalid To address' do - expect { api_client.deliver(message_with_invalid_to) }.to raise_error(Postmark::InvalidMessageError) + expect {api_client.deliver(message_with_invalid_to)}.to raise_error(Postmark::InvalidMessageError) end end - context "in batches" do - it 'returns as many responses as many messages were sent' do + context "batch message" do + it 'response messages count' do expect(api_client.deliver_in_batches(valid_messages).count).to eq valid_messages.count end - context "given custom max_batch_size" do + context "custom max_batch_size" do before do api_client.max_batch_size = 1 end - it 'returns as many responses as many messages were sent' do + it 'response message count' do expect(api_client.deliver_in_batches(valid_messages).count).to eq valid_messages.count end end it 'partially delivers a batch of partially valid Mail::Message objects' do response = api_client.deliver_in_batches(partially_valid_messages) - expect(response).to satisfy { |r| r.count { |mr| mr[:error_code].to_i.zero? } == 2 } + expect(response).to satisfy {|r| r.count {|mr| mr[:error_code].to_i.zero?} == 2} end it "doesn't deliver a batch of invalid Mail::Message objects" do response = api_client.deliver_in_batches(invalid_messages) - expect(response).to satisfy { |r| r.all? { |mr| !!mr[:error_code] } } + expect(response).to satisfy {|r| r.all? {|mr| !!mr[:error_code]}} end end end \ No newline at end of file diff --git a/spec/integration/api_client_messages_spec.rb b/spec/integration/api_client_messages_spec.rb index be5d7c2..8759431 100644 --- a/spec/integration/api_client_messages_spec.rb +++ b/spec/integration/api_client_messages_spec.rb @@ -42,21 +42,21 @@ end end - context "message by message" do - it 'delivers a plain text message' do + context "single message" do + it 'plain text message' do expect(api_client.deliver_message(message)).to have_key(:message_id) end - it 'updates a message object with Message-ID' do - expect(api_client.deliver_message(message)[:message_id]).to be =~ postmark_message_id_format + it 'message with attachment' do + expect(api_client.deliver_message(message_with_attachment)).to have_key(:message_id) end - it 'returns full Postmark response' do - expect(api_client.deliver_message(message)).to be_a Hash + it 'response Message-ID' do + expect(api_client.deliver_message(message)[:message_id]).to be =~ postmark_message_id_format end - it 'delivers a message with attachment' do - expect(api_client.deliver_message(message_with_attachment)).to have_key(:message_id) + it 'response is Hash' do + expect(api_client.deliver_message(message)).to be_a Hash end it 'fails to deliver a message without body' do @@ -68,37 +68,37 @@ end end - context "in batches" do - it 'delivers a batch of valid Mail::Message objects' do + context "batch message" do + it 'response - valid Mail::Message objects' do expect { api_client.deliver_messages(valid_messages) }. to change{valid_messages.all? { |m| m.delivered? }}.to true end - it 'updates delivered messages with X-PM-Message-Ids' do + it 'response - valid X-PM-Message-Ids' do api_client.deliver_messages(valid_messages) expect(valid_messages.all? { |m| m['X-PM-Message-Id'].to_s =~ postmark_message_id_format }).to be true end - it 'updates delivered messages with related Postmark responses' do + it 'response - valid response objects' do api_client.deliver_messages(valid_messages) expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).to be true end - it 'returns as many responses as many messages were sent' do + it 'response - message responses count' do expect(api_client.deliver_messages(valid_messages).count).to eq valid_messages.count end - context "given custom max_batch_size" do + context "custom max_batch_size" do before do api_client.max_batch_size = 1 end - it 'updates delivered messages with related Postmark responses' do + it 'response - valid response objects' do api_client.deliver_messages(valid_messages) expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).to be true end - it 'returns as many responses as many messages were sent' do + it 'response - message responses count' do expect(api_client.deliver_messages(valid_messages).count).to eq valid_messages.count end end diff --git a/spec/integration/api_client_resources_spec.rb b/spec/integration/api_client_resources_spec.rb index c8154b7..d42ca57 100644 --- a/spec/integration/api_client_resources_spec.rb +++ b/spec/integration/api_client_resources_spec.rb @@ -1,46 +1,36 @@ require 'spec_helper' describe 'Accessing server resources using the API' do - - let(:api_client) { - Postmark::ApiClient.new(ENV['POSTMARK_API_KEY'], :http_open_timeout => 15) - } - let(:recipient) { ENV['POSTMARK_CI_RECIPIENT'] } + let(:api_client) {Postmark::ApiClient.new(ENV['POSTMARK_API_KEY'], :http_open_timeout => 15)} + let(:recipient) {ENV['POSTMARK_CI_RECIPIENT']} let(:message) { { - :from => ENV['POSTMARK_CI_SENDER'], - :to => recipient, - :subject => "Mail::Message object", - :text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \ + :from => ENV['POSTMARK_CI_SENDER'], + :to => recipient, + :subject => "Mail::Message object", + :text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \ "sed do eiusmod tempor incididunt ut labore et dolore " \ "magna aliqua." } } context 'Triggers API' do - - let(:unique_token) { rand(36**32).to_s(36) } + let(:unique_token) {rand(36 ** 32).to_s(36)} it 'can be used to manage tag triggers via the API' do - trigger = api_client.create_trigger(:tags, - :match_name => "gemtest_#{unique_token}", - :track_opens => true) - api_client.update_trigger(:tags, - trigger[:id], - :match_name => "pre_#{trigger[:match_name]}") + trigger = api_client.create_trigger(:tags, :match_name => "gemtest_#{unique_token}", :track_opens => true) + api_client.update_trigger(:tags, trigger[:id], :match_name => "pre_#{trigger[:match_name]}") updated = api_client.get_trigger(:tags, trigger[:id]) expect(updated[:id]).to eq(trigger[:id]) expect(updated[:match_name]).not_to eq(trigger[:id]) - expect(api_client.triggers(:tags).map { |t| t[:id] }).to include(trigger[:id]) + expect(api_client.triggers(:tags).map {|t| t[:id]}).to include(trigger[:id]) api_client.delete_trigger(:tags, trigger[:id]) end - end context 'Messages API' do - def with_retries(max_retries = 20, wait_seconds = 3) yield rescue => e @@ -55,17 +45,13 @@ def with_retries(max_retries = 20, wait_seconds = 3) it 'is possible to send a message and access its details via the Messages API' do response = api_client.deliver(message) - message = with_retries { - api_client.get_message(response[:message_id]) - } + message = with_retries {api_client.get_message(response[:message_id])} expect(message[:recipients]).to include(recipient) end it 'is possible to send a message and dump it via the Messages API' do response = api_client.deliver(message) - dump = with_retries { - api_client.dump_message(response[:message_id]) - } + dump = with_retries {api_client.dump_message(response[:message_id])} expect(dump[:body]).to include('Mail::Message object') end @@ -74,15 +60,13 @@ def with_retries(max_retries = 20, wait_seconds = 3) expect { with_retries { messages = api_client.get_messages(:recipient => recipient, - :fromemail => message[:from], - :subject => message[:subject]) - unless messages.map { |m| m[:message_id] }.include?(response[:message_id]) + :fromemail => message[:from], + :subject => message[:subject]) + unless messages.map {|m| m[:message_id]}.include?(response[:message_id]) raise 'Message not found' end } }.not_to raise_error end - end - end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5c862c7..c589297 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -49,10 +49,3 @@ Postmark.response_parser_class = nil end end - -# define custom matchers -RSpec::Matchers.define :be_serialized_to do |json| - match do |mail_message| - Postmark.convert_message_to_options_hash(mail_message) == JSON.parse(json) - end -end diff --git a/spec/support/custom_matchers.rb b/spec/support/custom_matchers.rb index ab8b5a9..9501978 100644 --- a/spec/support/custom_matchers.rb +++ b/spec/support/custom_matchers.rb @@ -32,3 +32,9 @@ def postmark_json?(str) RSpec::Matchers.define :json_representation_of do |x| match { |actual| Postmark::Json.decode(actual) == x } end + +RSpec::Matchers.define :be_serialized_to do |json| + match do |mail_message| + Postmark.convert_message_to_options_hash(mail_message) == JSON.parse(json) + end +end diff --git a/spec/unit/postmark/account_api_client_spec.rb b/spec/unit/postmark/account_api_client_spec.rb index 1194c5b..065a8d7 100644 --- a/spec/unit/postmark/account_api_client_spec.rb +++ b/spec/unit/postmark/account_api_client_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe Postmark::AccountApiClient do - let(:api_token) { 'abcd-efgh' } subject { Postmark::AccountApiClient} @@ -14,7 +13,6 @@ end context 'instance' do - subject { Postmark::AccountApiClient.new(api_token) } it 'uses the auth header specific for Account API' do @@ -23,7 +21,6 @@ end describe '#senders' do - let(:response) { { 'TotalCount' => 10, 'SenderSignatures' => [{}, {}] @@ -44,11 +41,9 @@ with('senders', an_instance_of(Hash)).and_return(response) subject.senders.take(1000) end - end describe '#get_senders' do - let(:response) { { "TotalCount" => 1, @@ -86,11 +81,9 @@ and_return(response) subject.get_senders(:offset => 10, :count => 42) end - end describe '#get_senders_count' do - let(:response) { {'TotalCount' => 42} } it 'is aliased as #get_signatures_count' do @@ -103,11 +96,9 @@ with('senders', an_instance_of(Hash)).and_return(response) expect(subject.get_senders_count).to eq(42) end - end describe '#get_sender' do - let(:response) { { "Domain" => "example.com", @@ -137,7 +128,6 @@ end describe '#create_sender' do - let(:response) { { "Domain" => "example.com", @@ -173,7 +163,6 @@ end describe '#update_sender' do - let(:response) { { "Domain" => "example.com", @@ -207,11 +196,9 @@ keys = subject.update_sender(42, :foo => 'bar').keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#resend_sender_confirmation' do - let(:response) { { "ErrorCode" => 0, @@ -235,11 +222,9 @@ keys = subject.resend_sender_confirmation(42).keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#verified_sender_spf?' do - let(:response) { {"SPFVerified" => true} } let(:false_response) { {"SPFVerified" => false} } @@ -262,11 +247,9 @@ allow(subject.http_client).to receive(:post).and_return(response) expect(subject.verified_sender_spf?(42)).to be true end - end describe '#request_new_sender_dkim' do - let(:response) { { "Domain" => "example.com", @@ -294,11 +277,9 @@ keys = subject.request_new_sender_dkim(42).keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#delete_sender' do - let(:response) { { "ErrorCode" => 0, @@ -321,16 +302,10 @@ keys = subject.delete_sender(42).keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#domains' do - - let(:response) { - { - 'TotalCount' => 10, 'Domains' => [{}, {}] - } - } + let(:response) {{'TotalCount' => 10, 'Domains' => [{}, {}]}} it 'returns an enumerator' do expect(subject.domains).to be_kind_of(Enumerable) @@ -379,7 +354,6 @@ end describe '#get_domains_count' do - let(:response) { {'TotalCount' => 42} } it 'returns a total number of domains' do @@ -387,11 +361,9 @@ with('domains', an_instance_of(Hash)).and_return(response) expect(subject.get_domains_count).to eq(42) end - end describe '#get_domain' do - let(:response) { { "Name" => "example.com", @@ -413,7 +385,6 @@ end describe '#create_domain' do - let(:response) { { "Name" => "example.com", @@ -441,7 +412,6 @@ end describe '#update_domain' do - let(:response) { { "Name" => "example.com", @@ -467,11 +437,9 @@ keys = subject.update_domain(42, :foo => 'bar').keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#verified_domain_spf?' do - let(:response) { {"SPFVerified" => true} } let(:false_response) { {"SPFVerified" => false} } @@ -490,11 +458,9 @@ allow(subject.http_client).to receive(:post).and_return(response) expect(subject.verified_domain_spf?(42)).to be true end - end describe '#rotate_domain_dkim' do - let(:response) { { "Name" => "example.com", @@ -513,11 +479,9 @@ keys = subject.rotate_domain_dkim(42).keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#delete_domain' do - let(:response) { { "ErrorCode" => 0, @@ -536,11 +500,9 @@ keys = subject.delete_sender(42).keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#servers' do - let(:response) { {'TotalCount' => 10, 'Servers' => [{}, {}]} } it 'returns an enumerator' do @@ -552,11 +514,9 @@ with('servers', an_instance_of(Hash)).and_return(response) subject.servers.take(100) end - end describe '#get_servers' do - let(:response) { { 'TotalCount' => 1, @@ -602,7 +562,6 @@ end describe '#get_server' do - let(:response) { { "ID" => 7438, @@ -633,11 +592,9 @@ keys = subject.get_server(42).keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#get_servers_count' do - let(:response) { {'TotalCount' => 42} } it 'returns a total number of servers' do @@ -649,7 +606,6 @@ end describe '#create_server' do - let(:response) { { "Name" => "Staging Testing", @@ -680,7 +636,6 @@ keys = subject.create_server(:foo => 'bar').keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#update_server' do @@ -722,11 +677,9 @@ keys = subject.update_server(42, :foo => 'bar').keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#delete_server' do - let(:response) { { "ErrorCode" => "0", @@ -745,7 +698,6 @@ keys = subject.delete_server(42).keys expect(keys.all? { |k| k.is_a?(Symbol) }).to be true end - end describe '#push_templates' do @@ -777,5 +729,4 @@ end end - end diff --git a/spec/unit/postmark/client_spec.rb b/spec/unit/postmark/client_spec.rb index 718c343..78a51b7 100644 --- a/spec/unit/postmark/client_spec.rb +++ b/spec/unit/postmark/client_spec.rb @@ -1,13 +1,10 @@ require 'spec_helper' describe Postmark::Client do - subject { Postmark::Client.new('abcd-efgh') } describe 'instance' do - describe '#find_each' do - let(:path) { 'resources' } let(:name) { 'Resources' } let(:response) { @@ -44,9 +41,6 @@ to receive(:get).exactly(5).times.and_return(response) expect(subject.find_each(path, name, :count => 2).count).to eq(10) end - end - end - end \ No newline at end of file diff --git a/spec/unit/postmark/error_spec.rb b/spec/unit/postmark/error_spec.rb index f20cb8a..0fefa02 100644 --- a/spec/unit/postmark/error_spec.rb +++ b/spec/unit/postmark/error_spec.rb @@ -1,47 +1,47 @@ require 'spec_helper' describe(Postmark::Error) do - it { is_expected.to be_a(StandardError) } + it {is_expected.to be_a(StandardError)} end describe(Postmark::HttpClientError) do - it { is_expected.to be_a(Postmark::Error) } - it { expect(subject.retry?).to be true } + it {is_expected.to be_a(Postmark::Error)} + it {expect(subject.retry?).to be true} end describe(Postmark::HttpServerError) do - it { is_expected.to be_a(Postmark::Error) } + it {is_expected.to be_a(Postmark::Error)} describe '.build' do context 'picks an appropriate subclass for code' do - subject { Postmark::HttpServerError.build(code, Postmark::Json.encode({})) } + subject {Postmark::HttpServerError.build(code, Postmark::Json.encode({}))} context '401' do - let(:code) { '401' } + let(:code) {'401'} - it { is_expected.to be_a(Postmark::InvalidApiKeyError) } - its(:status_code) { is_expected.to eq 401 } + it {is_expected.to be_a(Postmark::InvalidApiKeyError)} + its(:status_code) {is_expected.to eq 401} end context '422' do - let(:code) { '422' } + let(:code) {'422'} - it { is_expected.to be_a(Postmark::ApiInputError) } - its(:status_code) { is_expected.to eq 422 } + it {is_expected.to be_a(Postmark::ApiInputError)} + its(:status_code) {is_expected.to eq 422} end context '500' do - let(:code) { '500' } + let(:code) {'500'} - it { is_expected.to be_a(Postmark::InternalServerError) } - its(:status_code) { is_expected.to eq 500 } + it {is_expected.to be_a(Postmark::InternalServerError)} + its(:status_code) {is_expected.to eq 500} end context 'others' do - let(:code) { '999' } + let(:code) {'999'} - it { is_expected.to be_a(Postmark::UnexpectedHttpResponseError) } - its(:status_code) { is_expected.to eq code.to_i } + it {is_expected.to be_a(Postmark::UnexpectedHttpResponseError)} + its(:status_code) {is_expected.to eq code.to_i} end end end @@ -62,7 +62,7 @@ describe '#message ' do it 'uses "Message" field on postmark response if available' do - data = { 'Message' => 'Postmark error message' } + data = {'Message' => 'Postmark error message'} error = Postmark::HttpServerError.new(502, Postmark::Json.encode(data), data) expect(error.message).to eq data['Message'] end @@ -77,28 +77,28 @@ describe(Postmark::ApiInputError) do describe '.build' do context 'picks an appropriate subclass for error code' do - let(:response) { { 'ErrorCode' => code } } + let(:response) {{'ErrorCode' => code}} subject do Postmark::ApiInputError.build(Postmark::Json.encode(response), response) end shared_examples_for 'api input error' do - its(:status_code) { is_expected. to eq 422 } - it { expect(subject.retry?).to be false } - it { is_expected.to be_a(Postmark::ApiInputError) } - it { is_expected.to be_a(Postmark::HttpServerError) } + its(:status_code) {is_expected.to eq 422} + it {expect(subject.retry?).to be false} + it {is_expected.to be_a(Postmark::ApiInputError)} + it {is_expected.to be_a(Postmark::HttpServerError)} end context '406' do - let(:code) { Postmark::ApiInputError::INACTIVE_RECIPIENT } + let(:code) {Postmark::ApiInputError::INACTIVE_RECIPIENT} - it { is_expected.to be_a(Postmark::InactiveRecipientError) } + it {is_expected.to be_a(Postmark::InactiveRecipientError)} it_behaves_like 'api input error' end context 'others' do - let(:code) { '9999' } + let(:code) {'9999'} it_behaves_like 'api input error' end @@ -107,7 +107,7 @@ end describe Postmark::InvalidTemplateError do - subject(:error) { Postmark::InvalidTemplateError.new(:foo => 'bar') } + subject(:error) {Postmark::InvalidTemplateError.new(:foo => 'bar')} it 'is created with a response' do expect(error.message).to start_with('Failed to render the template.') @@ -116,8 +116,8 @@ end describe(Postmark::TimeoutError) do - it { is_expected.to be_a(Postmark::Error) } - it { expect(subject.retry?).to be true } + it {is_expected.to be_a(Postmark::Error)} + it {expect(subject.retry?).to be true} end describe(Postmark::UnknownMessageType) do @@ -127,19 +127,19 @@ end describe(Postmark::InvalidApiKeyError) do - it { is_expected.to be_a(Postmark::Error) } + it {is_expected.to be_a(Postmark::Error)} end describe(Postmark::InternalServerError) do - it { is_expected.to be_a(Postmark::Error) } + it {is_expected.to be_a(Postmark::Error)} end describe(Postmark::UnexpectedHttpResponseError) do - it { is_expected.to be_a(Postmark::Error) } + it {is_expected.to be_a(Postmark::Error)} end describe(Postmark::MailAdapterError) do - it { is_expected.to be_a(Postmark::Error) } + it {is_expected.to be_a(Postmark::Error)} end describe(Postmark::InactiveRecipientError) do @@ -148,7 +148,7 @@ %w(nothing@wildbit.com noth.ing+2@wildbit.com noth.ing+2-1@wildbit.com) end - subject { Postmark::InactiveRecipientError.parse_recipients(message) } + subject {Postmark::InactiveRecipientError.parse_recipients(message)} context '1/1 inactive' do let(:message) do @@ -158,7 +158,7 @@ 'bounce or a spam complaint.' end - it { is_expected.to eq(recipients.take(1)) } + it {is_expected.to eq(recipients.take(1))} end context 'i/n inactive, n > 1, i < n' do @@ -168,7 +168,7 @@ 'have generated a hard bounce or a spam complaint.' end - it { is_expected.to eq(recipients.take(2)) } + it {is_expected.to eq(recipients.take(2))} end context 'n/n inactive, n > 1' do @@ -178,25 +178,25 @@ 'Inactive recipients are ones that have generated a hard bounce or a spam complaint.' end - it { is_expected.to eq(recipients) } + it {is_expected.to eq(recipients)} end context 'unknown error format' do - let(:message) { recipients.join(', ') } + let(:message) {recipients.join(', ')} - it { is_expected.to eq([]) } + it {is_expected.to eq([])} end end describe '.new' do - let(:address) { 'user@example.org' } - let(:response) { { 'Message' => message } } + let(:address) {'user@example.org'} + let(:response) {{'Message' => message}} subject do Postmark::InactiveRecipientError.new( - Postmark::ApiInputError::INACTIVE_RECIPIENT, - Postmark::Json.encode(response), - response) + Postmark::ApiInputError::INACTIVE_RECIPIENT, + Postmark::Json.encode(response), + response) end let(:message) do diff --git a/spec/unit/postmark/http_client_spec.rb b/spec/unit/postmark/http_client_spec.rb index 07c24bf..282a22c 100644 --- a/spec/unit/postmark/http_client_spec.rb +++ b/spec/unit/postmark/http_client_spec.rb @@ -3,7 +3,7 @@ describe Postmark::HttpClient do def response_body(status, message = "") - body = {"ErrorCode" => status, "Message" => message}.to_json + {"ErrorCode" => status, "Message" => message}.to_json end let(:api_token) { "provided-postmark-api-token" } @@ -218,6 +218,5 @@ def response_body(status, message = "") :status => [ "485", "Custom HTTP response status" ]) expect { subject.put(target_path) }.to raise_error Postmark::UnknownError end - end end \ No newline at end of file diff --git a/spec/unit/postmark/inflector_spec.rb b/spec/unit/postmark/inflector_spec.rb index 62e2ae3..f1f1601 100644 --- a/spec/unit/postmark/inflector_spec.rb +++ b/spec/unit/postmark/inflector_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe Postmark::Inflector do - describe ".to_postmark" do it 'converts rubyish underscored format to camel cased symbols accepted by the Postmark API' do expect(subject.to_postmark(:foo_bar)).to eq 'FooBar' diff --git a/spec/unit/postmark/mail_message_converter_spec.rb b/spec/unit/postmark/mail_message_converter_spec.rb index 8aea8d5..40f71e2 100644 --- a/spec/unit/postmark/mail_message_converter_spec.rb +++ b/spec/unit/postmark/mail_message_converter_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' describe Postmark::MailMessageConverter do - subject {Postmark::MailMessageConverter} let(:mail_message) do @@ -375,5 +374,4 @@ expect(mail_message.to_postmark_hash.keys).not_to include('Cc') end end - end