Skip to content

Conversation

@pirogoeth
Copy link
Contributor

@pirogoeth pirogoeth commented Nov 7, 2016

Super basic implementation of a "test mode" allowing users to easily stub calls that send emails.

Initially, it is just for stubbing the message sending routine, but can be expanded to stub other API calls if necessary.

Test mode is also tested. 😂

EDIT: Version has also been bumped to 1.1.2 for this feature.

@pirogoeth
Copy link
Contributor Author

@sixfeetover @michaelrkn Any ideas on this?

@michaelrkn
Copy link

This looks great! Thanks @pirogoeth!

}
end

self.new resp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I suggest using an OpenStruct here? Then if there ever was a time where you wanted more than body and code methods, you'll get them for free.

require 'ostruct`
self.new OpenStruct.new(h)

Whatever key values you pass into the from_hash method will be callable without checking if the key exists and defining a method for it if it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh absolutely! Thanks!

@sixfeetover
Copy link

This looks great, thank you. 👍

@pirogoeth pirogoeth merged commit 969c9a0 into mailgun:master Nov 11, 2016
api_version = 'v3',
ssl = true)
ssl = true,
test_mode = false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this default to Mailgun.test_mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kpandya91 So actually that's a really good point. It looks like Mailgun.test_mode was defined in an earlier commit but was never actually used? So this actually could make use of that field. I'll dig through the code again to make sure it's unused and add that as the default value. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants