email_spec 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt
CHANGED
|
@@ -4,6 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
=== Bufixes
|
|
6
6
|
|
|
7
|
+
== 0.5.0 2010-02-22
|
|
8
|
+
|
|
9
|
+
=== New features
|
|
10
|
+
* "should receive <x> emails with subject <the_subject>" step definition (Balint Erdi)
|
|
11
|
+
* "should recieve an email with the following body:" step definition (Ben Mabey)
|
|
12
|
+
* Debugging steps that tie into EmailViewer: (Ben Mabey)
|
|
13
|
+
* "save and open current email"
|
|
14
|
+
* "save and open all text emails"
|
|
15
|
+
* "save and open all html emails"
|
|
16
|
+
* "save and open all raw emails"
|
|
17
|
+
|
|
18
|
+
=== Bufixes
|
|
19
|
+
* Gracefuly handle cases where emails do not have a 'to' value. (Kieran Pilkington)
|
|
20
|
+
|
|
21
|
+
=== Bufixes
|
|
22
|
+
|
|
7
23
|
== 0.4.0 2010-01-07
|
|
8
24
|
|
|
9
25
|
=== New features
|
|
@@ -13,7 +13,10 @@ module EmailSpec
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def mailbox_for(address)
|
|
16
|
-
deliveries.select { |
|
|
16
|
+
deliveries.select { |email|
|
|
17
|
+
(email.to && email.to.include?(address)) ||
|
|
18
|
+
(email.bcc && email.bcc.include?(address)) ||
|
|
19
|
+
(email.cc && email.cc.include?(address)) }
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
protected
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module EmailSpec
|
|
2
2
|
class EmailViewer
|
|
3
3
|
extend Deliveries
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
def self.save_and_open_all_raw_emails
|
|
6
6
|
filename = "#{RAILS_ROOT}/tmp/email-#{Time.now.to_i}.txt"
|
|
7
7
|
|
|
@@ -44,7 +44,7 @@ module EmailSpec
|
|
|
44
44
|
|
|
45
45
|
open_in_text_editor(filename)
|
|
46
46
|
end
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
def self.save_and_open_email(mail)
|
|
49
49
|
filename = "#{RAILS_ROOT}/tmp/email-#{Time.now.to_i}.txt"
|
|
50
50
|
|
|
@@ -54,17 +54,18 @@ module EmailSpec
|
|
|
54
54
|
|
|
55
55
|
open_in_text_editor(filename)
|
|
56
56
|
end
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
# TODO: use the launchy gem for this stuff...
|
|
58
59
|
def self.open_in_text_editor(filename)
|
|
59
|
-
`
|
|
60
|
+
`open #{filename}`
|
|
60
61
|
end
|
|
61
|
-
|
|
62
|
+
|
|
62
63
|
def self.open_in_browser(filename)
|
|
63
64
|
`open #{filename}`
|
|
64
65
|
end
|
|
65
|
-
|
|
66
|
+
|
|
66
67
|
def self.tmp_email_filename(extension = '.txt')
|
|
67
68
|
"#{RAILS_ROOT}/tmp/email-#{Time.now.to_i}#{extension}"
|
|
68
69
|
end
|
|
69
70
|
end
|
|
70
|
-
end
|
|
71
|
+
end
|
|
@@ -56,6 +56,15 @@ Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amou
|
|
|
56
56
|
mailbox_for(address).size.should == parse_email_count(amount)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
|
60
|
+
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Then /^(?:I|they|"([^"]*?)") should recieve an email with the following body:$/ do |address, expected_body|
|
|
64
|
+
open_email(address, :with_text => expected_body)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
|
|
59
68
|
# DEPRECATED
|
|
60
69
|
# The following methods are left in for backwards compatibility and
|
|
61
70
|
# should be removed by version 0.4.0
|
|
@@ -141,3 +150,24 @@ When /^(?:I|they) click the first link in the email$/ do
|
|
|
141
150
|
click_first_link_in_email
|
|
142
151
|
end
|
|
143
152
|
|
|
153
|
+
#
|
|
154
|
+
# Debugging
|
|
155
|
+
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
|
156
|
+
# Patches accepted. ;)
|
|
157
|
+
#
|
|
158
|
+
|
|
159
|
+
Then /^save and open current email$/ do
|
|
160
|
+
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
Then /^save and open all text emails$/ do
|
|
164
|
+
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
Then /^save and open all html emails$/ do
|
|
168
|
+
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
Then /^save and open all raw emails$/ do
|
|
172
|
+
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
|
173
|
+
end
|
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.
|
|
4
|
+
version: 0.5.0
|
|
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: 2010-
|
|
14
|
+
date: 2010-02-22 00:00:00 -07:00
|
|
15
15
|
default_executable:
|
|
16
16
|
dependencies: []
|
|
17
17
|
|