Skip to content

Commit

Permalink
Send, reply, forward tests optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-mailosaur committed Oct 27, 2021
1 parent 47636b3 commit 11301e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion test/emails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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()
Expand All @@ -259,6 +262,7 @@ def startup
end

should 'forward with HTML content' do
omit_if(@@verified_domain.nil?)
target_email = @@emails[0]
body = '<p>Forwarded <strong>HTML</strong> message.</p>'
options = Mailosaur::Models::MessageForwardOptions.new()
Expand All @@ -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()
Expand All @@ -283,6 +288,7 @@ def startup
end

should 'reply with HTML content' do
omit_if(@@verified_domain.nil?)
target_email = @@emails[0]
body = '<p>Reply <strong>HTML</strong> message.</p>'
options = Mailosaur::Models::MessageForwardOptions.new()
Expand Down
2 changes: 1 addition & 1 deletion test/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 11301e4

Please sign in to comment.