email_spec 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  === Bufixes
6
6
 
7
+
8
+ == 0.3.7 2009-12-17
9
+
10
+ === New features
11
+ * Matchers are now Ruby 1.9 compatible. (John Dewey)
12
+
7
13
  == 0.3.6 2009-12-16
8
14
 
9
15
  === New features
Binary file
@@ -0,0 +1,122 @@
1
+ # Commonly used email steps
2
+ #
3
+ # To add your own steps make a custom_email_steps.rb
4
+ # The provided methods are:
5
+ #
6
+ # last_email_address
7
+ # reset_mailer
8
+ # open_last_email
9
+ # visit_in_email
10
+ # unread_emails_for
11
+ # mailbox_for
12
+ # current_email
13
+ # open_email
14
+ # read_emails_for
15
+ # find_email
16
+ #
17
+ # General form for email scenarios are:
18
+ # - clear the email queue (done automatically by email_spec)
19
+ # - execute steps that sends an email
20
+ # - check the user received an/no/[0-9] emails
21
+ # - open the email
22
+ # - inspect the email contents
23
+ # - interact with the email (e.g. click links)
24
+ #
25
+ # The Cucumber steps below are setup in this order.
26
+
27
+ module EmailHelpers
28
+ def current_email_address
29
+ # Replace with your a way to find your current email. e.g @current_user.email
30
+ # last_email_address will return the last email address used by email spec to find an email.
31
+ # Note that last_email_address will be reset after each Scenario.
32
+ last_email_address || "example@example.com"
33
+ end
34
+ end
35
+
36
+ World(EmailHelpers)
37
+
38
+ #
39
+ # Reset the e-mail queue within a scenario.
40
+ # This is done automatically before each scenario.
41
+ #
42
+
43
+ Given /^(?:a clear email queue|no emails have been sent)$/ do
44
+ reset_mailer
45
+ end
46
+
47
+ #
48
+ # Check how many emails have been sent/received
49
+ #
50
+
51
+ Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
52
+ unread_emails_for(address).size.should == parse_email_count(amount)
53
+ end
54
+
55
+ Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
56
+ mailbox_for(address).size.should == parse_email_count(amount)
57
+ end
58
+
59
+ # DEPRECATED
60
+ # The following methods are left in for backwards compatibility and
61
+ # should be removed by version 0.4.0
62
+ Then /^(?:I|they|"([^"]*?)") should not receive an email$/ do |address|
63
+ email_spec_deprecate "The step 'I/they/[email] should not receive an email' is no longer supported.
64
+ Please use 'I/they/[email] should receive no emails' instead."
65
+ unread_emails_for(address).size.should == 0
66
+ end
67
+
68
+ #
69
+ # Accessing emails
70
+ #
71
+
72
+ # Opens the most recently received email
73
+ When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
74
+ open_email(address)
75
+ end
76
+
77
+ When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
78
+ open_email(address, :with_subject => subject)
79
+ end
80
+
81
+ When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
82
+ open_email(address, :with_text => text)
83
+ end
84
+
85
+ #
86
+ # Inspect the Email Contents
87
+ #
88
+
89
+ Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
90
+ current_email.should have_subject(Regexp.new(text))
91
+ end
92
+
93
+ Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
94
+ current_email.body.should =~ Regexp.new(text)
95
+ end
96
+
97
+ # DEPRECATED
98
+ # The following methods are left in for backwards compatibility and
99
+ # should be removed by version 0.4.0.
100
+ Then /^(?:I|they) should see "([^"]*?)" in the subject$/ do |text|
101
+ email_spec_deprecate "The step 'I/they should see [text] in the subject' is no longer supported.
102
+ Please use 'I/they should see [text] in the email subject' instead."
103
+ current_email.should have_subject(Regexp.new(text))
104
+ end
105
+ Then /^(?:I|they) should see "([^"]*?)" in the email$/ do |text|
106
+ email_spec_deprecate "The step 'I/they should see [text] in the email' is no longer supported.
107
+ Please use 'I/they should see [text] in the email body' instead."
108
+ current_email.body.should =~ Regexp.new(text)
109
+ end
110
+
111
+ #
112
+ # Interact with Email Contents
113
+ #
114
+
115
+ When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
116
+ visit_in_email(link)
117
+ end
118
+
119
+ When /^(?:I|they) click the first link in the email$/ do
120
+ click_first_link_in_email
121
+ end
122
+
@@ -0,0 +1 @@
1
+ # Logfile created on Wed Dec 16 23:20:00 -0700 2009
@@ -0,0 +1,342 @@
1
+ # Logfile created on Wed Dec 16 23:20:02 -0700 2009 SQL (0.3ms)  SELECT name
2
+ FROM sqlite_master
3
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
4
+ 
5
+ SQL (0.2ms) select sqlite_version(*)
6
+ SQL (52.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
7
+ SQL (2.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
8
+ SQL (0.3ms)  SELECT name
9
+ FROM sqlite_master
10
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
11
+ 
12
+ SQL (0.1ms) SELECT version FROM schema_migrations
13
+ Migrating to CreateUsers (20090125013728)
14
+ SQL (0.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(255), "name" varchar(255)) 
15
+ SQL (0.1ms) INSERT INTO schema_migrations (version) VALUES ('20090125013728')
16
+ Migrating to CreateDelayedJobs (20090908054656)
17
+ SQL (0.3ms)  SELECT name
18
+ FROM sqlite_master
19
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
20
+ 
21
+ SQL (0.5ms) CREATE TABLE "delayed_jobs" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "priority" integer DEFAULT 0, "attempts" integer DEFAULT 0, "handler" text, "last_error" text, "run_at" datetime, "locked_at" datetime, "failed_at" datetime, "locked_by" varchar(255), "created_at" datetime, "updated_at" datetime) 
22
+ SQL (0.1ms) INSERT INTO schema_migrations (version) VALUES ('20090908054656')
23
+ SQL (0.4ms)  SELECT name
24
+ FROM sqlite_master
25
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
26
+ 
27
+ SQL (0.2ms) SELECT version FROM schema_migrations
28
+ SQL (0.2ms)  SELECT name
29
+ FROM sqlite_master
30
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
31
+ 
32
+ SQL (0.1ms) PRAGMA index_list("delayed_jobs")
33
+ SQL (0.1ms) PRAGMA index_list("users")
34
+ REQUESTING PAGE: GET http://www.example.com/newsletter?Email=example%40example.com&Name=Joe+Someone with {} and HTTP headers {}
35
+
36
+
37
+ Processing WelcomeController#newsletter (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
38
+ Parameters: {"Name"=>"Joe Someone", "Email"=>"example@example.com"}
39
+ Delayed::Job Create (0.4ms) INSERT INTO "delayed_jobs" ("locked_by", "updated_at", "handler", "priority", "run_at", "locked_at", "last_error", "attempts", "failed_at", "created_at") VALUES(NULL, '2009-12-17 06:20:07', '--- !ruby/struct:Delayed::PerformableMethod
40
+ object: CLASS:UserMailer
41
+ method: :deliver_newsletter
42
+ args:
43
+ - example@example.com
44
+ - Joe Someone
45
+ ', 0, '2009-12-17 06:20:07', NULL, NULL, 0, NULL, '2009-12-17 06:20:07')
46
+ Rendering welcome/newsletter
47
+ Completed in 57ms (View: 2, DB: 1) | 200 OK [http://www.example.com/newsletter?Email=example%40example.com&Name=Joe+Someone]
48
+ * [JOB] acquiring lock on UserMailer.deliver_newsletter
49
+ Delayed::Job Update (0.1ms) UPDATE "delayed_jobs" SET locked_at = '2009-12-17 06:20:07', locked_by = 'host:Benz pid:2220' WHERE (id = 1 and (locked_at is null or locked_at < '2009-12-17 02:20:07') and (run_at <= '2009-12-17 06:20:07')) 
50
+ Sent mail to example@example.com
51
+
52
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
53
+ From: admin@example.com
54
+ To: example@example.com
55
+ Subject: Newsletter sent
56
+ Mime-Version: 1.0
57
+ Content-Type: text/plain; charset=utf-8
58
+
59
+ Hello Joe Someone!
60
+
61
+ This week.....
62
+ .....
63
+ .....
64
+
65
+ Regards
66
+ Rails Example App
67
+ Delayed::Job Destroy (0.1ms) DELETE FROM "delayed_jobs" WHERE "id" = 1
68
+ * [JOB] UserMailer.deliver_newsletter completed after 0.0045
69
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
70
+
71
+
72
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
73
+ Rendering welcome/index
74
+ Completed in 2ms (View: 2, DB: 2) | 200 OK [http://www.example.com/]
75
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
76
+
77
+
78
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
79
+ Parameters: {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"}
80
+ Sent mail to example@example.com
81
+
82
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
83
+ From: admin@example.com
84
+ To: example@example.com
85
+ Subject: Account confirmation
86
+ Mime-Version: 1.0
87
+ Content-Type: text/plain; charset=utf-8
88
+
89
+ Hello !
90
+
91
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
92
+ Rendering welcome/signup
93
+ Completed in 5ms (View: 1, DB: 1) | 200 OK [http://www.example.com/welcome/signup]
94
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
95
+
96
+
97
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
98
+ Rendering welcome/index
99
+ Completed in 2ms (View: 1, DB: 1) | 200 OK [http://www.example.com/]
100
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
101
+
102
+
103
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
104
+ Parameters: {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"}
105
+ Sent mail to example@example.com
106
+
107
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
108
+ From: admin@example.com
109
+ To: example@example.com
110
+ Subject: Account confirmation
111
+ Mime-Version: 1.0
112
+ Content-Type: text/plain; charset=utf-8
113
+
114
+ Hello !
115
+
116
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
117
+ Rendering welcome/signup
118
+ Completed in 4ms (View: 0, DB: 1) | 200 OK [http://www.example.com/welcome/signup]
119
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
120
+
121
+
122
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
123
+ Rendering welcome/index
124
+ Completed in 2ms (View: 1, DB: 1) | 200 OK [http://www.example.com/]
125
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
126
+
127
+
128
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
129
+ Parameters: {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"}
130
+ Sent mail to example@example.com
131
+
132
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
133
+ From: admin@example.com
134
+ To: example@example.com
135
+ Subject: Account confirmation
136
+ Mime-Version: 1.0
137
+ Content-Type: text/plain; charset=utf-8
138
+
139
+ Hello !
140
+
141
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
142
+ Rendering welcome/signup
143
+ Completed in 4ms (View: 0, DB: 1) | 200 OK [http://www.example.com/welcome/signup]
144
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
145
+
146
+
147
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
148
+ Rendering welcome/index
149
+ Completed in 2ms (View: 1, DB: 1) | 200 OK [http://www.example.com/]
150
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
151
+
152
+
153
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
154
+ Parameters: {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"}
155
+ Sent mail to example@example.com
156
+
157
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
158
+ From: admin@example.com
159
+ To: example@example.com
160
+ Subject: Account confirmation
161
+ Mime-Version: 1.0
162
+ Content-Type: text/plain; charset=utf-8
163
+
164
+ Hello !
165
+
166
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
167
+ Rendering welcome/signup
168
+ Completed in 4ms (View: 1, DB: 1) | 200 OK [http://www.example.com/welcome/signup]
169
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
170
+
171
+
172
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
173
+ Rendering welcome/index
174
+ Completed in 2ms (View: 1, DB: 1) | 200 OK [http://www.example.com/]
175
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
176
+
177
+
178
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
179
+ Parameters: {"Name"=>"", "commit"=>"Sign up", "Email"=>"example@example.com"}
180
+ Sent mail to example@example.com
181
+
182
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
183
+ From: admin@example.com
184
+ To: example@example.com
185
+ Subject: Account confirmation
186
+ Mime-Version: 1.0
187
+ Content-Type: text/plain; charset=utf-8
188
+
189
+ Hello !
190
+
191
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
192
+ Rendering welcome/signup
193
+ Completed in 4ms (View: 0, DB: 1) | 200 OK [http://www.example.com/welcome/signup]
194
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
195
+
196
+
197
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
198
+ Rendering welcome/index
199
+ Completed in 2ms (View: 1, DB: 1) | 200 OK [http://www.example.com/]
200
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
201
+
202
+
203
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
204
+ Parameters: {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"}
205
+ Sent mail to example@example.com
206
+
207
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
208
+ From: admin@example.com
209
+ To: example@example.com
210
+ Subject: Account confirmation
211
+ Mime-Version: 1.0
212
+ Content-Type: text/plain; charset=utf-8
213
+
214
+ Hello Joe Someone!
215
+
216
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
217
+ Rendering welcome/signup
218
+ Completed in 4ms (View: 0, DB: 0) | 200 OK [http://www.example.com/welcome/signup]
219
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/welcome/signup"}
220
+
221
+
222
+ Processing WelcomeController#confirm (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
223
+ Rendering welcome/confirm
224
+ Completed in 1ms (View: 1, DB: 2) | 200 OK [http://www.example.com/confirm]
225
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
226
+
227
+
228
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
229
+ Rendering welcome/index
230
+ Completed in 2ms (View: 1, DB: 1) | 200 OK [http://www.example.com/]
231
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
232
+
233
+
234
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
235
+ Parameters: {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"}
236
+ Sent mail to example@example.com
237
+
238
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
239
+ From: admin@example.com
240
+ To: example@example.com
241
+ Subject: Account confirmation
242
+ Mime-Version: 1.0
243
+ Content-Type: text/plain; charset=utf-8
244
+
245
+ Hello Joe Someone!
246
+
247
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
248
+ Rendering welcome/signup
249
+ Completed in 4ms (View: 0, DB: 0) | 200 OK [http://www.example.com/welcome/signup]
250
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/welcome/signup"}
251
+
252
+
253
+ Processing WelcomeController#confirm (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
254
+ Rendering welcome/confirm
255
+ Completed in 1ms (View: 0, DB: 2) | 200 OK [http://www.example.com/confirm]
256
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
257
+
258
+
259
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
260
+ Rendering welcome/index
261
+ Completed in 2ms (View: 1, DB: 1) | 200 OK [http://www.example.com/]
262
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
263
+
264
+
265
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
266
+ Parameters: {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"}
267
+ Sent mail to example@example.com
268
+
269
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
270
+ From: admin@example.com
271
+ To: example@example.com
272
+ Subject: Account confirmation
273
+ Mime-Version: 1.0
274
+ Content-Type: text/plain; charset=utf-8
275
+
276
+ Hello Joe Someone!
277
+
278
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
279
+ Rendering welcome/signup
280
+ Completed in 4ms (View: 0, DB: 0) | 200 OK [http://www.example.com/welcome/signup]
281
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/welcome/signup"}
282
+
283
+
284
+ Processing WelcomeController#confirm (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
285
+ Rendering welcome/confirm
286
+ Completed in 1ms (View: 0, DB: 1) | 200 OK [http://www.example.com/confirm]
287
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
288
+
289
+
290
+ Processing WelcomeController#index (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
291
+ Rendering welcome/index
292
+ Completed in 1ms (View: 1, DB: 0) | 200 OK [http://www.example.com/]
293
+ REQUESTING PAGE: POST /welcome/signup with {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
294
+
295
+
296
+ Processing WelcomeController#signup (for 127.0.0.1 at 2009-12-16 23:20:07) [POST]
297
+ Parameters: {"Name"=>"Joe Someone", "commit"=>"Sign up", "Email"=>"example@example.com"}
298
+ Sent mail to example@example.com
299
+
300
+ Date: Wed, 16 Dec 2009 23:20:07 -0700
301
+ From: admin@example.com
302
+ To: example@example.com
303
+ Subject: Account confirmation
304
+ Mime-Version: 1.0
305
+ Content-Type: text/plain; charset=utf-8
306
+
307
+ Hello Joe Someone!
308
+
309
+ <a href="http://example.com/confirm">Click here to confirm your account!</a>
310
+ Rendering welcome/signup
311
+ Completed in 4ms (View: 0, DB: 0) | 200 OK [http://www.example.com/welcome/signup]
312
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/welcome/signup"}
313
+
314
+
315
+ Processing WelcomeController#confirm (for 127.0.0.1 at 2009-12-16 23:20:07) [GET]
316
+ Rendering welcome/confirm
317
+ Completed in 1ms (View: 0, DB: 1) | 200 OK [http://www.example.com/confirm]
318
+ SQL (0.6ms)  SELECT name
319
+ FROM sqlite_master
320
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
321
+ 
322
+ SQL (0.2ms) SELECT version FROM schema_migrations
323
+ Migrating to CreateUsers (20090125013728)
324
+ Migrating to CreateDelayedJobs (20090908054656)
325
+ SQL (0.2ms) select sqlite_version(*)
326
+ SQL (0.2ms)  SELECT name
327
+ FROM sqlite_master
328
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
329
+ 
330
+ SQL (0.2ms) SELECT version FROM schema_migrations
331
+ SQL (0.3ms)  SELECT name
332
+ FROM sqlite_master
333
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
334
+ 
335
+ SQL (0.1ms) PRAGMA index_list("delayed_jobs")
336
+ SQL (0.0ms) PRAGMA index_list("users")
337
+
338
+
339
+ Processing WelcomeController#signup (for 0.0.0.0 at 2009-12-16 23:20:18) [POST]
340
+ Parameters: {"Name"=>"Jimmy Bean", "Email"=>"email@example.com"}
341
+ Rendering welcome/signup
342
+ Completed in 3ms (View: 0, DB: 0) | 200 OK [http://test.host/welcome/signup?Email=email%40example.com&Name=Jimmy+Bean]
@@ -0,0 +1,17 @@
1
+ # This generator adds email steps to the step definitions directory
2
+ generator_base = defined?(Rails) ? Rails::Generator::Base : RubiGen::Base
3
+ class EmailSpecGenerator < generator_base
4
+ def manifest
5
+ record do |m|
6
+ m.directory 'features/step_definitions'
7
+ m.file 'email_steps.rb', 'features/step_definitions/email_steps.rb'
8
+ end
9
+ end
10
+
11
+ protected
12
+
13
+ def banner
14
+ "Usage: #{$0} email_spec"
15
+ end
16
+
17
+ end
@@ -0,0 +1,122 @@
1
+ # Commonly used email steps
2
+ #
3
+ # To add your own steps make a custom_email_steps.rb
4
+ # The provided methods are:
5
+ #
6
+ # last_email_address
7
+ # reset_mailer
8
+ # open_last_email
9
+ # visit_in_email
10
+ # unread_emails_for
11
+ # mailbox_for
12
+ # current_email
13
+ # open_email
14
+ # read_emails_for
15
+ # find_email
16
+ #
17
+ # General form for email scenarios are:
18
+ # - clear the email queue (done automatically by email_spec)
19
+ # - execute steps that sends an email
20
+ # - check the user received an/no/[0-9] emails
21
+ # - open the email
22
+ # - inspect the email contents
23
+ # - interact with the email (e.g. click links)
24
+ #
25
+ # The Cucumber steps below are setup in this order.
26
+
27
+ module EmailHelpers
28
+ def current_email_address
29
+ # Replace with your a way to find your current email. e.g @current_user.email
30
+ # last_email_address will return the last email address used by email spec to find an email.
31
+ # Note that last_email_address will be reset after each Scenario.
32
+ last_email_address || "example@example.com"
33
+ end
34
+ end
35
+
36
+ World(EmailHelpers)
37
+
38
+ #
39
+ # Reset the e-mail queue within a scenario.
40
+ # This is done automatically before each scenario.
41
+ #
42
+
43
+ Given /^(?:a clear email queue|no emails have been sent)$/ do
44
+ reset_mailer
45
+ end
46
+
47
+ #
48
+ # Check how many emails have been sent/received
49
+ #
50
+
51
+ Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
52
+ unread_emails_for(address).size.should == parse_email_count(amount)
53
+ end
54
+
55
+ Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
56
+ mailbox_for(address).size.should == parse_email_count(amount)
57
+ end
58
+
59
+ # DEPRECATED
60
+ # The following methods are left in for backwards compatibility and
61
+ # should be removed by version 0.4.0
62
+ Then /^(?:I|they|"([^"]*?)") should not receive an email$/ do |address|
63
+ email_spec_deprecate "The step 'I/they/[email] should not receive an email' is no longer supported.
64
+ Please use 'I/they/[email] should receive no emails' instead."
65
+ unread_emails_for(address).size.should == 0
66
+ end
67
+
68
+ #
69
+ # Accessing emails
70
+ #
71
+
72
+ # Opens the most recently received email
73
+ When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
74
+ open_email(address)
75
+ end
76
+
77
+ When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
78
+ open_email(address, :with_subject => subject)
79
+ end
80
+
81
+ When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
82
+ open_email(address, :with_text => text)
83
+ end
84
+
85
+ #
86
+ # Inspect the Email Contents
87
+ #
88
+
89
+ Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
90
+ current_email.should have_subject(Regexp.new(text))
91
+ end
92
+
93
+ Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
94
+ current_email.body.should =~ Regexp.new(text)
95
+ end
96
+
97
+ # DEPRECATED
98
+ # The following methods are left in for backwards compatibility and
99
+ # should be removed by version 0.4.0.
100
+ Then /^(?:I|they) should see "([^"]*?)" in the subject$/ do |text|
101
+ email_spec_deprecate "The step 'I/they should see [text] in the subject' is no longer supported.
102
+ Please use 'I/they should see [text] in the email subject' instead."
103
+ current_email.should have_subject(Regexp.new(text))
104
+ end
105
+ Then /^(?:I|they) should see "([^"]*?)" in the email$/ do |text|
106
+ email_spec_deprecate "The step 'I/they should see [text] in the email' is no longer supported.
107
+ Please use 'I/they should see [text] in the email body' instead."
108
+ current_email.body.should =~ Regexp.new(text)
109
+ end
110
+
111
+ #
112
+ # Interact with Email Contents
113
+ #
114
+
115
+ When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
116
+ visit_in_email(link)
117
+ end
118
+
119
+ When /^(?:I|they) click the first link in the email$/ do
120
+ click_first_link_in_email
121
+ end
122
+
@@ -0,0 +1,23 @@
1
+ # Logfile created on Wed Dec 16 23:20:14 -0700 2009 by /
2
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
3
+ REQUESTING PAGE: POST /signup with {"user[name]"=>nil, "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
4
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
5
+ REQUESTING PAGE: POST /signup with {"user[name]"=>nil, "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
6
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
7
+ REQUESTING PAGE: POST /signup with {"user[name]"=>nil, "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
8
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
9
+ REQUESTING PAGE: POST /signup with {"user[name]"=>nil, "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
10
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
11
+ REQUESTING PAGE: POST /signup with {"user[name]"=>nil, "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
12
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
13
+ REQUESTING PAGE: POST /signup with {"user[name]"=>"Joe Someone", "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
14
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/signup"}
15
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
16
+ REQUESTING PAGE: POST /signup with {"user[name]"=>"Joe Someone", "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
17
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/signup"}
18
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
19
+ REQUESTING PAGE: POST /signup with {"user[name]"=>"Joe Someone", "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
20
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/signup"}
21
+ REQUESTING PAGE: GET / with {} and HTTP headers {}
22
+ REQUESTING PAGE: POST /signup with {"user[name]"=>"Joe Someone", "user[email]"=>"example@example.com"} and HTTP headers {"HTTP_REFERER"=>"/"}
23
+ REQUESTING PAGE: GET /confirm with {} and HTTP headers {"HTTP_REFERER"=>"/signup"}
@@ -18,7 +18,7 @@ module EmailSpec
18
18
 
19
19
  def matches?(email)
20
20
  @email = email
21
- @actual_recipients = (email.to || []).sort
21
+ @actual_recipients = (Array(email.to) || []).sort
22
22
  @actual_recipients == @expected_email_addresses
23
23
  end
24
24
 
@@ -84,7 +84,7 @@ module EmailSpec
84
84
 
85
85
  def matches?(email)
86
86
  @email = email
87
- @actual_recipients = (email.bcc || []).sort
87
+ @actual_recipients = (Array(email.bcc) || []).sort
88
88
  @actual_recipients == @expected_email_addresses
89
89
  end
90
90
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Mabey
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-12-16 00:00:00 -07:00
14
+ date: 2009-12-17 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
@@ -98,14 +98,18 @@ test_files:
98
98
  - examples/rails_root/db/migrate/20090125013728_create_users.rb
99
99
  - examples/rails_root/db/migrate/20090908054656_create_delayed_jobs.rb
100
100
  - examples/rails_root/db/schema.rb
101
+ - examples/rails_root/db/test.sqlite3
101
102
  - examples/rails_root/doc/README_FOR_APP
102
103
  - examples/rails_root/features/delayed_job.feature
103
104
  - examples/rails_root/features/errors.feature
104
105
  - examples/rails_root/features/example.feature
106
+ - examples/rails_root/features/step_definitions/email_steps.rb
105
107
  - examples/rails_root/features/step_definitions/user_steps.rb
106
108
  - examples/rails_root/features/step_definitions/webrat_steps.rb
107
109
  - examples/rails_root/features/support/env.rb
108
110
  - examples/rails_root/features/support/paths.rb
111
+ - examples/rails_root/log/development.log
112
+ - examples/rails_root/log/test.log
109
113
  - examples/rails_root/public/404.html
110
114
  - examples/rails_root/public/422.html
111
115
  - examples/rails_root/public/500.html
@@ -145,6 +149,8 @@ test_files:
145
149
  - examples/rails_root/spec/rcov.opts
146
150
  - examples/rails_root/spec/spec.opts
147
151
  - examples/rails_root/spec/spec_helper.rb
152
+ - examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/email_spec_generator.rb
153
+ - examples/rails_root/vendor/plugins/email_spec/rails_generators/email_spec/templates/email_steps.rb
148
154
  - examples/sinatra/app.rb
149
155
  - examples/sinatra/features/errors.feature
150
156
  - examples/sinatra/features/example.feature
@@ -152,3 +158,4 @@ test_files:
152
158
  - examples/sinatra/features/step_definitions/webrat_steps.rb
153
159
  - examples/sinatra/features/support/env.rb
154
160
  - examples/sinatra/features/support/paths.rb
161
+ - examples/sinatra/webrat.log