Clone wiki

mandrill-api-ruby / Home

Testing

The Mandrill API gem itself doesn't provide a method to enter a "test" mode where the connection to Mandrill is mocked. So if you run your tests often - as you should - you're potentially going to generate lots and lots of emails. Mandrill uses Excon to connect to the remote API. Therefore, it's important to mock that interface.

To do that with Rspec, open your spec_helper.rb and add this to rspec's config block:

config.before(:all) do 
  Excon.defaults[:mock] = true
  Excon.stub({}, {body: '{}', status: 200}) # stubs any request to return an empty JSON string
end

Updated