> For the complete documentation index, see [llms.txt](https://ploegert.gitbook.io/til/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ploegert.gitbook.io/til/programmy/rails/make-action-mailer-synchronous-in-test.md).

# Make ActionMailer Synchronous In Test

When you set up an `ActionMailer` email, the default configuration is for it to use `ActiveJob` to send the emails. [As of Rails 5, it will do so asynchronously.](https://blog.bigbinary.com/2016/03/29/rails-5-changed-default-active-job-adapter-to-async.html). Depending on your preferences for testing emails, you may prefer `ActiveJob` to send the emails synchronously. This can be done by changing the `queue_adapter` back to `:inline` in your `config/environments/test.rb`.

```ruby
config.active_job.queue_adapter = :inline
```

If you also configure the `delivery_method` as `:test`:

```ruby
config.action_mailer.delivery_method = :test
```

then emails will be queued up in `ActionMailer::Base.deliveries` allowing you to write a test like this:

```ruby
expect(ActionMailer::Base.deliveries.count).to eq(1)
```

Check out [the docs](https://guides.rubyonrails.org/action_mailer_basics.html) for more on `ActionMailer`.

[source](https://stackoverflow.com/a/42987726/535590)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/rails/make-action-mailer-synchronous-in-test.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
