spec/railtie_spec.rb in simple_postmark-0.5.1 vs spec/railtie_spec.rb in simple_postmark-0.5.2

- old
+ new

@@ -1,21 +1,21 @@ -require File.expand_path('../spec_helper', __FILE__) +require_relative 'spec_helper' require 'action_mailer' require 'rails' require 'simple_postmark/railtie' ActionMailer::Base.delivery_method = :simple_postmark class NotificationMailer < ActionMailer::Base default from: 'barney@himym.tld', to: 'ted@himym.tld' def im_your_bro - mail(subject: "I'm your bro!") + mail(subject: "I'm your bro!", body: '') end def im_your_bro_tagged - mail(subject: "I'm your bro!", tag: 'simple-postmark') + mail(subject: "I'm your bro!", tag: 'simple-postmark', body: '') end def im_your_bro_multipart mail(subject: "I'm your bro!") do |as| as.html { render(text: "<p>Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome.<br /><br />I'm your bro-I'm Broda!</p>" )} @@ -23,11 +23,11 @@ end end def the_bro_code attachments['thebrocode.jpg'] = File.read(File.join(File.dirname(__FILE__), 'thebrocode.jpg')) - mail(subject: 'The Brocode!') + mail(subject: 'The Brocode!', body: '') end end def merge_body(hash = {}) Hash[*body.merge(hash).sort.flatten(1)].to_json @@ -64,11 +64,11 @@ end it 'allows setting an api key' do ActionMailer::Base.simple_postmark_settings = { api_key: api_key } - + ActionMailer::Base.simple_postmark_settings[:api_key].must_equal(api_key) end describe 'sending mails' do @@ -77,42 +77,42 @@ end it 'works' do NotificationMailer.im_your_bro.deliver - + assert_requested(:post, url, headers: headers, body: merge_body) end it 'allows tags' do NotificationMailer.im_your_bro_tagged.deliver - + assert_requested(:post, url, headers: headers, body: merge_body('Tag' => 'simple-postmark')) end it 'works with attachments' do attachment = { 'Content' => [File.read(File.join(File.dirname(__FILE__), 'thebrocode.jpg'))].pack('m'), 'ContentType' => 'image/jpeg', 'Name' => 'thebrocode.jpg' } - + NotificationMailer.the_bro_code.deliver - + assert_requested(:post, url, headers: headers, body: merge_body('Subject' => 'The Brocode!', 'Attachments' => [attachment])) end it 'works with multipart messages' do bodies = { 'HtmlBody' => "<p>Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome.<br /><br />I'm your bro-I'm Broda!</p>", 'TextBody' => "Think of me like Yoda, but instead of being little and green I wear suits and I'm awesome. I'm your bro-I'm Broda!" } - + NotificationMailer.im_your_bro_multipart.deliver - + assert_requested(:post, url, headers: headers, body: merge_body(bodies)) end end -end \ No newline at end of file +end