p0deje / action_mailer_cache_delivery

Cache delivery method for ActionMailer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Action Mailer Cache Delivery Build Status Gem Version

Enhances ActionMailer to support the :cache delivery method, which behaves like :test, except that the deliveries are marshalled to a temporary cache file, thus making them available to other processes.

You'll want to use this gem if you're testing with Selenium (or any other tool which distinct processes). Another approach would be to share deliveries between threads (in this case, this gem is not needed at all).

Installation

Add to Gemfile

gem 'action_mailer_cache_delivery'

Now run bundle install

Usage

Change delivery method in your config/environments/test.rb

config.action_mailer.delivery_method = :cache

You can optionally specify location for cache file.

config.action_mailer.cache_settings = { :location => "#{Rails.root}/tmp/mail.cache" }

To access the cached deliveries in another process, just do

ActionMailer::Base.cached_deliveries

Use with parallel_tests

If you use parallel_tests to run your tests in parallel, you may get unexpected errors like EOFError. If so, make sure cache files differ for processes. Change you config/environment/test.rb

config.action_mailer.cache_settings = { :location => "#{Rails.root}/tmp/cache/action_mailer_cache_delivery#{ENV['TEST_ENV_NUMBER']}.cache" }

Contributors

I tried to list there everyone who forked original version on GitHub. If you're not here, just send pull request.

About

Cache delivery method for ActionMailer

License:MIT License


Languages

Language:Ruby 100.0%