From 11301e443689ccad928dda5c1e83839f36928dc2 Mon Sep 17 00:00:00 2001 From: Jon Mahoney Date: Wed, 27 Oct 2021 17:44:02 +0100 Subject: [PATCH] Send, reply, forward tests optional --- README.md | 1 - test/emails_test.rb | 8 +++++++- test/mailer.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 48abd6a..8c76835 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,6 @@ The test suite requires the following environment variables to be set: export MAILOSAUR_BASE_URL=https://mailosaur.com/ export MAILOSAUR_API_KEY=your_api_key export MAILOSAUR_SERVER=server_id -export MAILOSAUR_VERIFIED_DOMAIN=server_domain ``` Run all tests: diff --git a/test/emails_test.rb b/test/emails_test.rb index f52af60..a821ceb 100644 --- a/test/emails_test.rb +++ b/test/emails_test.rb @@ -15,7 +15,7 @@ def startup @@server = ENV['MAILOSAUR_SERVER'] @@verified_domain = ENV['MAILOSAUR_VERIFIED_DOMAIN'] - raise ArgumentError, 'Missing necessary environment variables - refer to README.md' if api_key.nil? || @@server.nil? || @@verified_domain.nil? + raise ArgumentError, 'Missing necessary environment variables - refer to README.md' if api_key.nil? || @@server.nil? @@client = MailosaurClient.new(api_key, base_url) @@ -222,6 +222,7 @@ def startup context 'create_and_send' do should 'send with text content' do + omit_if(@@verified_domain.nil?) subject = 'New message' options = Mailosaur::Models::MessageCreateOptions.new() options.to = 'anything@%s' % [@@verified_domain] @@ -234,6 +235,7 @@ def startup end should 'send with HTML content' do + omit_if(@@verified_domain.nil?) subject = 'New HTML message' options = Mailosaur::Models::MessageCreateOptions.new() options.to = 'anything@%s' % [@@verified_domain] @@ -248,6 +250,7 @@ def startup context 'forward' do should 'forward with text content' do + omit_if(@@verified_domain.nil?) target_email = @@emails[0] body = 'Forwarded message' options = Mailosaur::Models::MessageForwardOptions.new() @@ -259,6 +262,7 @@ def startup end should 'forward with HTML content' do + omit_if(@@verified_domain.nil?) target_email = @@emails[0] body = '

Forwarded HTML message.

' options = Mailosaur::Models::MessageForwardOptions.new() @@ -272,6 +276,7 @@ def startup context 'reply' do should 'reply with text content' do + omit_if(@@verified_domain.nil?) target_email = @@emails[0] body = 'Reply message' options = Mailosaur::Models::MessageForwardOptions.new() @@ -283,6 +288,7 @@ def startup end should 'reply with HTML content' do + omit_if(@@verified_domain.nil?) target_email = @@emails[0] body = '

Reply HTML message.

' options = Mailosaur::Models::MessageForwardOptions.new() diff --git a/test/mailer.rb b/test/mailer.rb index b6a32cb..285c90f 100644 --- a/test/mailer.rb +++ b/test/mailer.rb @@ -12,7 +12,7 @@ class Mailer @@html = File.open('test/resources/testEmail.html').read @@text = File.open('test/resources/testEmail.txt').read - @@verified_domain = ENV['MAILOSAUR_VERIFIED_DOMAIN'] + @@verified_domain = ENV['MAILOSAUR_VERIFIED_DOMAIN'] || 'mailosaur.net' def self.send_emails(client, server, quantity) (1..quantity).each do |_i|