gardelea-email_spec 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +257 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.md +277 -0
- data/Rakefile +17 -0
- data/lib/email-spec.rb +1 -0
- data/lib/email_spec.rb +18 -0
- data/lib/email_spec/address_converter.rb +29 -0
- data/lib/email_spec/background_processes.rb +45 -0
- data/lib/email_spec/cucumber.rb +26 -0
- data/lib/email_spec/deliveries.rb +91 -0
- data/lib/email_spec/email_viewer.rb +91 -0
- data/lib/email_spec/errors.rb +7 -0
- data/lib/email_spec/helpers.rb +175 -0
- data/lib/email_spec/mail_ext.rb +11 -0
- data/lib/email_spec/matchers.rb +257 -0
- data/lib/email_spec/test_observer.rb +7 -0
- data/lib/generators/email_spec/steps/USAGE +5 -0
- data/lib/generators/email_spec/steps/steps_generator.rb +14 -0
- data/lib/generators/email_spec/steps/templates/email_steps.rb +206 -0
- data/rails_generators/email_spec/email_spec_generator.rb +17 -0
- data/rails_generators/email_spec/templates/email_steps.rb +195 -0
- metadata +109 -0
data/History.txt
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
== 1.3.x (git)
|
2
|
+
|
3
|
+
* removing jeweler in favor of just using bundler for all that gem management type stuff
|
4
|
+
|
5
|
+
== 1.3.0 2011-04-07
|
6
|
+
|
7
|
+
Many thanks to Derek Hammer and George Ardeleanu who both spontaneously cleaned up various parts of the project
|
8
|
+
and helped get the release out the door. Yay opensoruce!
|
9
|
+
|
10
|
+
=== New features
|
11
|
+
* Launchy is now used to open up the email viewer. (Matt Burke)
|
12
|
+
* Email Viewer now works in Rails 3 (Woody Peterson)
|
13
|
+
* Email Viewer now works with UTF-8. (Woody Peterson)
|
14
|
+
* Documentation for email matchers. (Derek Hammer)
|
15
|
+
|
16
|
+
== 1.2.1 2011-06-20
|
17
|
+
|
18
|
+
=== Bugfixes
|
19
|
+
* find_email now allows with_subject and with_text to be either a String or Regexp. Issue #67. (Curtis Miller)
|
20
|
+
|
21
|
+
== 1.2.0 2011-06-16
|
22
|
+
|
23
|
+
=== New features
|
24
|
+
* [he|she] options for steps. (Dan Croak)
|
25
|
+
* cc_to RSpec matcher. (Arie on github)
|
26
|
+
* Check both html and text parts of multipart emails in Cucumber step. (Charles Barbier)
|
27
|
+
* delivery_method is not set by email_spec to allow for SMTP (e.g. MockSMTP) delivery (Donald Piret)
|
28
|
+
|
29
|
+
=== Bugfixes
|
30
|
+
* delivered_to matcher now compares both sender name and email address. (Jason Garber)
|
31
|
+
* find_email now matches with_subject and with_text containing text with regex sensitive characters. Issue #31. (Curtis Miller)
|
32
|
+
* current_email_address to work outside of the context of Cucumber. (Szymon Przybył)
|
33
|
+
|
34
|
+
== 1.1.1 2010-12-29
|
35
|
+
* Require "action_mailer" to avoid deprecation warnings. (Ryan Bigg)
|
36
|
+
* Relaxes pessimistic version dependency on RSpec. (GH-41 Dan Pickett)
|
37
|
+
|
38
|
+
== 1.1.0 2010-12-20
|
39
|
+
|
40
|
+
=== Bugfixes
|
41
|
+
* anchor tags are no longer ignored when clicking links in emails (Anders Törnqist and Nicklas Ramhöj)
|
42
|
+
* set_current_email handles cases where To to blank but may contain CC, or BCC recipients (Murray Steele)
|
43
|
+
* Doc fixes (Florent Guilleux)
|
44
|
+
|
45
|
+
|
46
|
+
== 1.0 2010-07-31 Rails 3.0 Release
|
47
|
+
This release makes email-spec compatible with Rails 3 and RSpec 2.x.
|
48
|
+
|
49
|
+
IMPORTANT: As of 1.0 email-spec is no longer backwards compatible wit Rails 2.x. I will be maintaining a 0.6
|
50
|
+
branch on github/rubygems for Rails 2 compatibility if anyone wants new features backported.
|
51
|
+
|
52
|
+
This was truly a community effort and I appreciate all of time and effort donated by those involved. Specifically:
|
53
|
+
* Maxim Chernyak for the initial conversion work to Rails 3
|
54
|
+
* Tim Harper for ironing out various matcher bugs
|
55
|
+
* Patrick Muldoon for doing a fantastic job of cleaning up the features and specs. He also fixed the
|
56
|
+
DelayedJob support and worked through all the bundler issues the project was facing.
|
57
|
+
|
58
|
+
=== Bugfixes
|
59
|
+
* Further checks for older DelayedJob versions to fix compatibility issues. (Andrea Longhi and others)
|
60
|
+
|
61
|
+
== 0.6.2 2010-03-21
|
62
|
+
|
63
|
+
=== New features
|
64
|
+
* New reply_to matcher. (David Balatero)
|
65
|
+
|
66
|
+
== 0.6.1 2010-03-17
|
67
|
+
|
68
|
+
=== New features
|
69
|
+
* Ability to click image links via the image alt tag. (Tim Harper)
|
70
|
+
|
71
|
+
== 0.6.0 2010-03-05
|
72
|
+
|
73
|
+
=== New features
|
74
|
+
* Ability to open a list of attachments on an email (with corresponding steps and EmailViewer support). (Kieran Pilkington)
|
75
|
+
|
76
|
+
=== Bugfixes
|
77
|
+
* Spelling mistake in steps. (Ben Mabey)
|
78
|
+
* Delayed Job background processor fixes
|
79
|
+
* Narrow delayed job collisions with other apps defining Delayed constant. (Kieran Pilkington)
|
80
|
+
* Fix compatibility with earlier versions of DelayedJob (Michael Baumgarten and Kieran Pilkington)
|
81
|
+
|
82
|
+
=== Changes
|
83
|
+
* Deprecated steps were removed. (Kieran Pilkington)
|
84
|
+
|
85
|
+
=== Bugfixes
|
86
|
+
|
87
|
+
== 0.5.0 2010-02-22
|
88
|
+
|
89
|
+
=== New features
|
90
|
+
* "should receive <x> emails with subject <the_subject>" step definition (Balint Erdi)
|
91
|
+
* "should receive an email with the following body:" step definition (Ben Mabey)
|
92
|
+
* Debugging steps that tie into EmailViewer: (Ben Mabey)
|
93
|
+
* "save and open current email"
|
94
|
+
* "save and open all text emails"
|
95
|
+
* "save and open all html emails"
|
96
|
+
* "save and open all raw emails"
|
97
|
+
|
98
|
+
=== Bugfixes
|
99
|
+
* Gracefully handle cases where emails do not have a 'to' value. (Kieran Pilkington)
|
100
|
+
|
101
|
+
=== Bugfixes
|
102
|
+
|
103
|
+
== 0.4.0 2010-01-07
|
104
|
+
|
105
|
+
=== New features
|
106
|
+
* Added support for action_mailer_cache_delivery plugin. (Dan Dofter)
|
107
|
+
You must use the fork at: http://github.com/liangzan/action_mailer_cache_delivery
|
108
|
+
|
109
|
+
=== Bugfixes
|
110
|
+
* be_delivered_from matcher now compares both sender name and email address. (Dan Dofter)
|
111
|
+
|
112
|
+
== 0.3.8 2009-12-23
|
113
|
+
|
114
|
+
=== Bugfixes
|
115
|
+
* Guard against cc and bcc fields being nil for ActionMailer. (Piotr Sarnacki)
|
116
|
+
|
117
|
+
== 0.3.7 2009-12-17
|
118
|
+
|
119
|
+
=== New features
|
120
|
+
* Matchers are now Ruby 1.9 compatible. (John Dewey)
|
121
|
+
|
122
|
+
== 0.3.6 2009-12-16
|
123
|
+
|
124
|
+
=== New features
|
125
|
+
* Cucumber steps for be_delivered_from, have_header matchers. (Joseph Holsten)
|
126
|
+
* Explicit regular expression steps. i.e. "I should see /foo/ in the email body" (Joseph Holsten)
|
127
|
+
|
128
|
+
== 0.3.5 2009-09-30 The Pony Release!
|
129
|
+
|
130
|
+
=== New features
|
131
|
+
* Support for Pony mailer library. (Rob Holland)
|
132
|
+
|
133
|
+
== 0.3.4 2009-09-26
|
134
|
+
|
135
|
+
=== Bugfixes
|
136
|
+
* Typo and logic fixes for DeliverFrom matcher. (Yury Kotlyarov)
|
137
|
+
|
138
|
+
== 0.3.3 2009-09-18
|
139
|
+
|
140
|
+
=== New features
|
141
|
+
* DeliverFrom matcher. i.e. email.should deliver_from(blah) or email.should be_delivered_from(blah) (Diego Carrion)
|
142
|
+
|
143
|
+
== 0.3.2 2009-09-10
|
144
|
+
|
145
|
+
=== New features
|
146
|
+
* Support for delayed_job. (Kieran Pilkington)
|
147
|
+
|
148
|
+
== 0.3.1 2009-08-19
|
149
|
+
This release is a general refactoring of the steps and helpers.
|
150
|
+
The example rails app was also updated to use the lateset rails and webrat. It also takes advantages
|
151
|
+
and the newer step definistions including the new third-person forms.
|
152
|
+
|
153
|
+
Some of the generated steps are being removed in favor of some of the newer ones. The older ones
|
154
|
+
will remain until 0.4.0 but will issue deprecation warnings.
|
155
|
+
|
156
|
+
Big shoutout to Kieran Pilkington who did the majority of work for this release.
|
157
|
+
|
158
|
+
== 0.3.0 2009-08-13
|
159
|
+
|
160
|
+
=== New features
|
161
|
+
* New helper #last_email_address which returns the last address used by email-spec for that scenario. (Ben Mabey)
|
162
|
+
* Steps now support third person language. (Kieran P)
|
163
|
+
* "[email] should receive ... " now supports "an" instead of just an integer. (Kieran Pilkington)
|
164
|
+
With these changes, the following is now possible:
|
165
|
+
|
166
|
+
Then "jack@example.com" should receive an email
|
167
|
+
When they open the email
|
168
|
+
Then they should see "Account has been created" in the subject
|
169
|
+
|
170
|
+
* Additional default steps (Balint Erdi)
|
171
|
+
* Then /^I should not receive any emails?$/
|
172
|
+
* When %r{^"([^"]*?)" opens? the email$} do |address|
|
173
|
+
|
174
|
+
=== Bugfixes
|
175
|
+
|
176
|
+
== 0.2.1 2009-5-29
|
177
|
+
|
178
|
+
=== New Features
|
179
|
+
* BCC RSpec matcher. (Josh Nichols)
|
180
|
+
|
181
|
+
=== Bugfixes
|
182
|
+
* Include BCCed and CCed messsages in the mailbox. (Jakub Kosiński)
|
183
|
+
|
184
|
+
== 0.2.0 2009-6-08
|
185
|
+
No changes. Bumping version for RubyForge release.
|
186
|
+
|
187
|
+
|
188
|
+
== 0.1.4 2009-5-29
|
189
|
+
|
190
|
+
=== Bugfixes
|
191
|
+
* Require deliveries in the helpers so it doesn't blow up with RSpec. (Craig Webster)
|
192
|
+
|
193
|
+
== 0.1.3 2009-4-15
|
194
|
+
|
195
|
+
=== Bugfixes
|
196
|
+
* Fixed regular expressions in genertaed steps. (Ben Mabey)
|
197
|
+
* World semantics changed in cucumber (0.2.3.2), email_spec now uses the new API. (Hector Morales)
|
198
|
+
|
199
|
+
== 0.1.2 2009-4-05
|
200
|
+
|
201
|
+
=== New features
|
202
|
+
=== Bugfixes
|
203
|
+
* Actually added the renamed generators to the gem so people could use it! D'oh! (Ben Mabey)
|
204
|
+
* You can either use "./script generate email_spec" or "rubigen rails email_spec"
|
205
|
+
* Removed Rake tasks from example application to prevent conflicts when used as a plugin. (Ben Mabey)
|
206
|
+
|
207
|
+
== 0.1.1 2009-3-26
|
208
|
+
=== New features
|
209
|
+
* Switched dir structure over to support rubigen. (Dr. Nic)
|
210
|
+
|
211
|
+
=== Bugfixes
|
212
|
+
|
213
|
+
== 0.1.0 2009-3-25
|
214
|
+
=== New features
|
215
|
+
* Change Rakefile to run all specs and features, as well as prepare the db (Mischa Fierer)
|
216
|
+
* Allow for array to be passed into deliver_to matcher. (Diego Carrion)
|
217
|
+
* Added matcher for checking if a collision of emails includes an email with a particular subject (Luke Melia, Noah Davis)
|
218
|
+
* Introduced hook to convert objects to email addresses (Luke Melia and Lee Bankewitz)
|
219
|
+
|
220
|
+
This allows you, in your step matcher, to say something like:
|
221
|
+
maillbox_for(some_user)
|
222
|
+
|
223
|
+
Use it in your cucumber env.rb like so:
|
224
|
+
|
225
|
+
EmailSpec::AddressConverter.instance.conversion do |input|
|
226
|
+
if input.is_a?(User)
|
227
|
+
input.email
|
228
|
+
else
|
229
|
+
input
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
=== Bugfixes
|
234
|
+
* Revert parse_email_for_link helper method to allow for text links as well as explicit link finding. (Mischa Fierer)
|
235
|
+
* Isolated variances between using email-spec with an ARMailer project. (Luke Melia)
|
236
|
+
|
237
|
+
|
238
|
+
== 0.0.9 2009-2-15
|
239
|
+
=== New features
|
240
|
+
* have_body_text, have_header matchers (Luke Melia)
|
241
|
+
* EmailViewer - opens all sent emails in a given scenario when the environment variables are set. (Luke Melia)
|
242
|
+
* Added compatibility with using ARMailer in test mode. (Luke Melia)
|
243
|
+
=== Bugfixes
|
244
|
+
* set_current_email now works with multiple addresses in To field. (Brian McManus, Ben Mabey)
|
245
|
+
|
246
|
+
== 0.0.7 2009-1-20
|
247
|
+
=== New features
|
248
|
+
* have_subject matcher (Ben Mabey)
|
249
|
+
|
250
|
+
== 0.0.6 2008-12-23
|
251
|
+
=== New features
|
252
|
+
* Improved RSpec documentation and refactorings. (Ben Mabey)
|
253
|
+
=== Bugfixes
|
254
|
+
* Removed sample app Rake Tasks to have it play nice with environments that use Cucumber as plugin- not gem. (Ben Mabey, Ivor- on github)
|
255
|
+
|
256
|
+
== 0.0.5 2008-12-18
|
257
|
+
* Initial release - see this post for full history and contributors: http://www.benmabey.com/2008/12/18/github-rocks/
|
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008-2009 Ben Mabey
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
|
2
|
+
[![Build Status](https://secure.travis-ci.org/bmabey/email-spec.png)](http://travis-ci.org/bmabey/email-spec)
|
3
|
+
|
4
|
+
## Email Spec
|
5
|
+
|
6
|
+
A collection of RSpec matchers and Cucumber steps to make testing emails go smoothly.
|
7
|
+
|
8
|
+
This library works with ActionMailer and Pony. When using it with ActionMailer it works with
|
9
|
+
DelayedJob, ActiveRecord Mailer, and action_mailer_cache_delivery.
|
10
|
+
|
11
|
+
If you are testing emails in conjunction with an automated browser solution, like Selenium,
|
12
|
+
you will want to use [action_mailer_cache_delivery](http://rubygems.org/gems/action_mailer_cache_delivery) in your test environment. (This is
|
13
|
+
because your test process and server processes are distinct and therefore need an
|
14
|
+
intermediate store for the emails.) DelayedJob and ActiveRecord Mailer will also work but
|
15
|
+
you generally don't want to include those projects unless you need them in production.
|
16
|
+
|
17
|
+
## Setup
|
18
|
+
|
19
|
+
```bash
|
20
|
+
script/plugin install git://github.com/bmabey/email-spec.git
|
21
|
+
```
|
22
|
+
|
23
|
+
### Gem Setup
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem install email_spec
|
27
|
+
|
28
|
+
# Gemfile
|
29
|
+
group :test do
|
30
|
+
gem 'email_spec'
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
### Cucumber
|
35
|
+
|
36
|
+
To use the steps in features put the following in your env.rb:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
# Make sure this require is after you require cucumber/rails/world.
|
40
|
+
require 'email_spec' # add this line if you use spork
|
41
|
+
require 'email_spec/cucumber'
|
42
|
+
```
|
43
|
+
|
44
|
+
This will load all the helpers that the steps rely on.
|
45
|
+
It will also add a Before hook for Cucumber so that emails are cleared at the start of each scenario.
|
46
|
+
|
47
|
+
Then:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
rails generate email_spec:steps
|
51
|
+
```
|
52
|
+
|
53
|
+
This will give you a bunch of steps to get started with in step_definitions/email_steps.rb
|
54
|
+
|
55
|
+
By default, the generated file will look for email to example@example.com. You can either change this
|
56
|
+
by editing the current_email_address method in email_steps.rb, or by simply specifying the target
|
57
|
+
email in your features:
|
58
|
+
|
59
|
+
```gherkin
|
60
|
+
Scenario: A new person signs up
|
61
|
+
Given I am at "/"
|
62
|
+
When I fill in "Email" with "quentin@example.com"
|
63
|
+
And I press "Sign up"
|
64
|
+
And "quentin@example.com" should receive an email # Specify who should receive the email
|
65
|
+
```
|
66
|
+
|
67
|
+
### RSpec
|
68
|
+
|
69
|
+
First you need to require email_spec in your spec_helper.rb:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
require "email_spec"
|
73
|
+
```
|
74
|
+
|
75
|
+
You will then need to include EmailSpec::Helpers and EmailSpec::Matchers in your example groups.
|
76
|
+
If you want to have access to the helpers and matchers in all of your examples you can do the following in your spec_helper.rb:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
RSpec.configure do |config|
|
80
|
+
config.include(EmailSpec::Helpers)
|
81
|
+
config.include(EmailSpec::Matchers)
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
Otherwise, you will need to include them in the example groups you wish to use them:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
describe "Signup Email" do
|
89
|
+
include EmailSpec::Helpers
|
90
|
+
include EmailSpec::Matchers
|
91
|
+
...
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
## Usage
|
96
|
+
|
97
|
+
### Cucumber
|
98
|
+
|
99
|
+
```gherkin
|
100
|
+
Scenario: A new person signs up
|
101
|
+
Given I am at "/"
|
102
|
+
When I fill in "Email" with "quentin@example.com"
|
103
|
+
And I press "Sign up"
|
104
|
+
And I should receive an email
|
105
|
+
When I open the email
|
106
|
+
Then I should see "confirm" in the email body
|
107
|
+
When I follow "confirm" in the email
|
108
|
+
Then I should see "Confirm your new account"
|
109
|
+
```
|
110
|
+
|
111
|
+
For more examples, check out examples/rails_root in the source for a small example app that implements these steps.
|
112
|
+
|
113
|
+
### Cucumber Matchers (Ruby)
|
114
|
+
|
115
|
+
See RSpec Matchers (they are the same)
|
116
|
+
|
117
|
+
### RSpec
|
118
|
+
|
119
|
+
#### Testing In Isolation
|
120
|
+
It is often useful to test your mailers in isolation. You can accomplish this by using mocks to verify that the mailer is being called in the correct place and then write focused examples for the actual mailer. This is a simple example from the sample app found in the gem:
|
121
|
+
|
122
|
+
Verify that the mailer is used correctly in the controller (this would apply to a model as well):
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
describe "POST /signup (#signup)" do
|
126
|
+
it "should deliver the signup email" do
|
127
|
+
# expect
|
128
|
+
UserMailer.should_receive(:deliver_signup).with("email@example.com", "Jimmy Bean")
|
129
|
+
# when
|
130
|
+
post :signup, "Email" => "email@example.com", "Name" => "Jimmy Bean"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
Examples for the #signup method in UserMailer:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
describe "Signup Email" do
|
139
|
+
include EmailSpec::Helpers
|
140
|
+
include EmailSpec::Matchers
|
141
|
+
# include ActionController::UrlWriter - old rails
|
142
|
+
include Rails.application.routes.url_helpers
|
143
|
+
|
144
|
+
before(:all) do
|
145
|
+
@email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should be set to be delivered to the email passed in" do
|
149
|
+
@email.should deliver_to("jojo@yahoo.com")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should contain the user's message in the mail body" do
|
153
|
+
@email.should have_body_text(/Jojo Binks/)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should contain a link to the confirmation link" do
|
157
|
+
@email.should have_body_text(/#{confirm_account_url}/)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should have the correct subject" do
|
161
|
+
@email.should have_subject(/Account confirmation/)
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
```
|
166
|
+
|
167
|
+
#### RSpec Matchers
|
168
|
+
|
169
|
+
##### reply_to(email)
|
170
|
+
alias: `have_reply_to`
|
171
|
+
|
172
|
+
This checks that the Reply-To header's email address (the bob@example.com of
|
173
|
+
"Bob Saget <bob@example.com>") is set to the given string.
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
177
|
+
email.should reply_to("support@myapp.com")
|
178
|
+
```
|
179
|
+
|
180
|
+
|
181
|
+
##### deliver_to(*email_addresses)
|
182
|
+
alias: `be_delivered_to`
|
183
|
+
|
184
|
+
This checks that the To header's email addresses (the bob@example.com of
|
185
|
+
"Bob Saget <bob@example.com>") are set to the addresses.
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
189
|
+
email.should deliver_to("jojo@yahoo.com")
|
190
|
+
```
|
191
|
+
|
192
|
+
|
193
|
+
##### deliver_from(email)
|
194
|
+
alias: `be_delivered_from`
|
195
|
+
|
196
|
+
This checks that the From header's email address (the bob@example.com of
|
197
|
+
"Bob Saget <bob@example.com>") is set to the given string.
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
201
|
+
email.should deliver_from("sally@yahoo.com")
|
202
|
+
```
|
203
|
+
|
204
|
+
|
205
|
+
##### bcc_to(*email_addresses)
|
206
|
+
|
207
|
+
This checks that the BCC header's email addresses (the bob@example.com of
|
208
|
+
"Bob Saget <bob@example.com>") are set to the addresses.
|
209
|
+
|
210
|
+
```ruby
|
211
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
212
|
+
email.should bcc_to("sue@yahoo.com", "bill@yahoo.com")
|
213
|
+
```
|
214
|
+
|
215
|
+
|
216
|
+
##### cc_to(*email_addresses)
|
217
|
+
|
218
|
+
This checks that the CC header's email addresses (the bob@example.com of
|
219
|
+
"Bob Saget <bob@example.com>") are set to the addresses.
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
223
|
+
email.should cc_to("sue@yahoo.com", "bill@yahoo.com")
|
224
|
+
```
|
225
|
+
|
226
|
+
|
227
|
+
##### have_subject(subject)
|
228
|
+
|
229
|
+
This checks that the Subject header's value is set to the given subject.
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
233
|
+
email.should have_subject("Welcome!")
|
234
|
+
```
|
235
|
+
|
236
|
+
|
237
|
+
##### include_email_with_subject(subject)
|
238
|
+
Note: subject can be either a String or a Regexp
|
239
|
+
|
240
|
+
This checks that one of the given emails' subjects includes the subject.
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
244
|
+
email2 = UserMailer.forgot_password("jojo@yahoo.com", "Jojo Binks")
|
245
|
+
[email, email2].should include_email_with_subject("Welcome!")
|
246
|
+
```
|
247
|
+
|
248
|
+
|
249
|
+
##### have_body_text(text)
|
250
|
+
Note: text can be either a String or a Regexp
|
251
|
+
|
252
|
+
This checks that the text of the body has the given body.
|
253
|
+
|
254
|
+
```ruby
|
255
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
256
|
+
email.should have_body_text(/Hi Jojo Binks,/)
|
257
|
+
```
|
258
|
+
|
259
|
+
|
260
|
+
##### have_header(key, value)
|
261
|
+
|
262
|
+
This checks that the expected key/value pair is in the headers of the email.
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
|
266
|
+
email.should have_header("X-Campaign", "1234abc")
|
267
|
+
```
|
268
|
+
|
269
|
+
#### Using the helpers when not testing in isolation
|
270
|
+
|
271
|
+
Don't. :) Seriously, if you do just take a look at the helpers and use them as you wish.
|
272
|
+
|
273
|
+
## Original Authors
|
274
|
+
|
275
|
+
Ben Mabey, Aaron Gibralter, Mischa Fierer
|
276
|
+
|
277
|
+
Please see History.txt for upcoming changsets and other contributors.
|