email_spec 1.0.1 → 1.1.1
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 +24 -12
- data/README.rdoc +4 -3
- data/Rakefile +4 -1
- data/examples/rails3_root/Gemfile.lock +3 -2
- data/lib/email_spec/deliveries.rb +5 -1
- data/lib/email_spec/helpers.rb +10 -6
- data/lib/email_spec.rb +1 -1
- data/rails_generators/email_spec/templates/email_steps.rb +1 -1
- data/spec/email_spec/helpers_spec.rb +115 -0
- metadata +22 -5
data/History.txt
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
== 1.
|
|
1
|
+
== 1.2 (git)
|
|
2
|
+
|
|
3
|
+
== 1.1.1 2010-12-29
|
|
4
|
+
* Require "action_mailer" to avoid deprecation warnings. (Ryan Bigg)
|
|
5
|
+
* Relaxes pessimistic version dependency on RSpec. (GH-41 Dan Pickett)
|
|
6
|
+
|
|
7
|
+
== 1.1.0 2010-12-20
|
|
8
|
+
|
|
9
|
+
=== Bugfixes
|
|
10
|
+
* anchor tags are no longer ignored when clicking links in emails (Anders Törnqist and Nicklas Ramhöj)
|
|
11
|
+
* set_current_email handles cases where To to blank but may contain CC, or BCC recipients (Murray Steele)
|
|
12
|
+
* Doc fixes (Florent Guilleux)
|
|
13
|
+
|
|
2
14
|
|
|
3
15
|
== 1.0 2010-07-31 Rails 3.0 Release
|
|
4
16
|
This release makes email-spec compatible with Rails 3 and RSpec 2.x.
|
|
@@ -39,7 +51,7 @@
|
|
|
39
51
|
=== Changes
|
|
40
52
|
* Deprecated steps were removed. (Kieran Pilkington)
|
|
41
53
|
|
|
42
|
-
===
|
|
54
|
+
=== Bugfixes
|
|
43
55
|
|
|
44
56
|
== 0.5.0 2010-02-22
|
|
45
57
|
|
|
@@ -52,10 +64,10 @@
|
|
|
52
64
|
* "save and open all html emails"
|
|
53
65
|
* "save and open all raw emails"
|
|
54
66
|
|
|
55
|
-
===
|
|
67
|
+
=== Bugfixes
|
|
56
68
|
* Gracefully handle cases where emails do not have a 'to' value. (Kieran Pilkington)
|
|
57
69
|
|
|
58
|
-
===
|
|
70
|
+
=== Bugfixes
|
|
59
71
|
|
|
60
72
|
== 0.4.0 2010-01-07
|
|
61
73
|
|
|
@@ -63,12 +75,12 @@
|
|
|
63
75
|
* Added support for action_mailer_cache_delivery plugin. (Dan Dofter)
|
|
64
76
|
You must use the fork at: http://github.com/liangzan/action_mailer_cache_delivery
|
|
65
77
|
|
|
66
|
-
===
|
|
78
|
+
=== Bugfixes
|
|
67
79
|
* be_delivered_from matcher now compares both sender name and email address. (Dan Dofter)
|
|
68
80
|
|
|
69
81
|
== 0.3.8 2009-12-23
|
|
70
82
|
|
|
71
|
-
===
|
|
83
|
+
=== Bugfixes
|
|
72
84
|
* Guard against cc and bcc fields being nil for ActionMailer. (Piotr Sarnacki)
|
|
73
85
|
|
|
74
86
|
== 0.3.7 2009-12-17
|
|
@@ -128,7 +140,7 @@ Big shoutout to Kieran Pilkington who did the majority of work for this release.
|
|
|
128
140
|
* Then /^I should not receive any emails?$/
|
|
129
141
|
* When %r{^"([^"]*?)" opens? the email$} do |address|
|
|
130
142
|
|
|
131
|
-
===
|
|
143
|
+
=== Bugfixes
|
|
132
144
|
|
|
133
145
|
== 0.2.1 2009-5-29
|
|
134
146
|
|
|
@@ -144,19 +156,19 @@ No changes. Bumping version for RubyForge release.
|
|
|
144
156
|
|
|
145
157
|
== 0.1.4 2009-5-29
|
|
146
158
|
|
|
147
|
-
===
|
|
159
|
+
=== Bugfixes
|
|
148
160
|
* Require deliveries in the helpers so it doesn't blow up with RSpec. (Craig Webster)
|
|
149
161
|
|
|
150
162
|
== 0.1.3 2009-4-15
|
|
151
163
|
|
|
152
|
-
===
|
|
164
|
+
=== Bugfixes
|
|
153
165
|
* Fixed regular expressions in genertaed steps. (Ben Mabey)
|
|
154
166
|
* World semantics changed in cucumber (0.2.3.2), email_spec now uses the new API. (Hector Morales)
|
|
155
167
|
|
|
156
168
|
== 0.1.2 2009-4-05
|
|
157
169
|
|
|
158
170
|
=== New features
|
|
159
|
-
===
|
|
171
|
+
=== Bugfixes
|
|
160
172
|
* Actually added the renamed generators to the gem so people could use it! D'oh! (Ben Mabey)
|
|
161
173
|
* You can either use "./script generate email_spec" or "rubigen rails email_spec"
|
|
162
174
|
* Removed Rake tasks from example application to prevent conflicts when used as a plugin. (Ben Mabey)
|
|
@@ -165,7 +177,7 @@ No changes. Bumping version for RubyForge release.
|
|
|
165
177
|
=== New features
|
|
166
178
|
* Switched dir structure over to support rubigen. (Dr. Nic)
|
|
167
179
|
|
|
168
|
-
===
|
|
180
|
+
=== Bugfixes
|
|
169
181
|
|
|
170
182
|
== 0.1.0 2009-3-25
|
|
171
183
|
=== New features
|
|
@@ -187,7 +199,7 @@ No changes. Bumping version for RubyForge release.
|
|
|
187
199
|
end
|
|
188
200
|
end
|
|
189
201
|
|
|
190
|
-
===
|
|
202
|
+
=== Bugfixes
|
|
191
203
|
* Revert parse_email_for_link helper method to allow for text links as well as explicit link finding. (Mischa Fierer)
|
|
192
204
|
* Isolated variances between using email-spec with an ARMailer project. (Luke Melia)
|
|
193
205
|
|
data/README.rdoc
CHANGED
|
@@ -32,6 +32,7 @@ you generally don't want to include those projects unless you need them in produ
|
|
|
32
32
|
To use the steps in features put the following in your env.rb:
|
|
33
33
|
|
|
34
34
|
# Make sure this require is after you require cucumber/rails/world.
|
|
35
|
+
require 'email_spec' # add this line if you use spork
|
|
35
36
|
require 'email_spec/cucumber'
|
|
36
37
|
|
|
37
38
|
This will load all the helpers that the steps rely on.
|
|
@@ -75,7 +76,7 @@ Otherwise, you will need to include them in the example groups you wish to use t
|
|
|
75
76
|
And I press "Sign up"
|
|
76
77
|
And I should receive an email
|
|
77
78
|
When I open the email
|
|
78
|
-
Then I should see "confirm" in the email
|
|
79
|
+
Then I should see "confirm" in the email body
|
|
79
80
|
When I follow "confirm" in the email
|
|
80
81
|
Then I should see "Confirm your new account"
|
|
81
82
|
|
|
@@ -113,11 +114,11 @@ Examples for the #signup method in UserMailer:
|
|
|
113
114
|
end
|
|
114
115
|
|
|
115
116
|
it "should contain the user's message in the mail body" do
|
|
116
|
-
@email.should
|
|
117
|
+
@email.should have_body_text(/Jojo Binks/)
|
|
117
118
|
end
|
|
118
119
|
|
|
119
120
|
it "should contain a link to the confirmation link" do
|
|
120
|
-
@email.should
|
|
121
|
+
@email.should have_body_text(/#{confirm_account_url}/)
|
|
121
122
|
end
|
|
122
123
|
|
|
123
124
|
it "should have the correct subject" do
|
data/Rakefile
CHANGED
|
@@ -22,7 +22,7 @@ begin
|
|
|
22
22
|
s.has_rdoc = true
|
|
23
23
|
s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
|
|
24
24
|
s.rubyforge_project = 'email-spec'
|
|
25
|
-
s.add_runtime_dependency
|
|
25
|
+
s.add_runtime_dependency "rspec", "~> 2.0"
|
|
26
26
|
end
|
|
27
27
|
rescue LoadError
|
|
28
28
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
|
@@ -52,8 +52,11 @@ task :default => [:features, :spec, 'example_app:spec']
|
|
|
52
52
|
desc "Cleans the project of any tmp file that should not be included in the gemspec."
|
|
53
53
|
task :clean do
|
|
54
54
|
#remove stuff from example rails apps
|
|
55
|
+
FileUtils.rm_rf("examples/rails_root")
|
|
56
|
+
FileUtils.rm_rf("examples/sinatra")
|
|
55
57
|
%w[ rails3 sinatra ].each do |ver|
|
|
56
58
|
FileUtils.rm_f("examples/#{ver}_root/features/step_definitions/email_steps.rb")
|
|
59
|
+
FileUtils.rm_f("examples/#{ver}_root/rerun.txt")
|
|
57
60
|
FileUtils.rm_rf("examples/#{ver}_root/log")
|
|
58
61
|
FileUtils.rm_rf("examples/#{ver}_root/vendor")
|
|
59
62
|
end
|
data/lib/email_spec/helpers.rb
CHANGED
|
@@ -13,14 +13,12 @@ module EmailSpec
|
|
|
13
13
|
def click_email_link_matching(regex, email = current_email)
|
|
14
14
|
url = links_in_email(email).detect { |link| link =~ regex }
|
|
15
15
|
raise "No link found matching #{regex.inspect} in #{email.default_part_body}" unless url
|
|
16
|
-
request_uri
|
|
17
|
-
visit request_uri
|
|
16
|
+
visit request_uri(url)
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
def click_first_link_in_email(email = current_email)
|
|
21
20
|
link = links_in_email(email).first
|
|
22
|
-
request_uri
|
|
23
|
-
visit request_uri
|
|
21
|
+
visit request_uri(link)
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
def open_email(address, opts={})
|
|
@@ -88,7 +86,7 @@ module EmailSpec
|
|
|
88
86
|
|
|
89
87
|
def set_current_email(email)
|
|
90
88
|
return unless email
|
|
91
|
-
email.to.each do |to|
|
|
89
|
+
[email.to, email.cc, email.bcc].compact.flatten.each do |to|
|
|
92
90
|
read_emails_for(to) << email
|
|
93
91
|
email_spec_hash[:current_emails][to] = email
|
|
94
92
|
end
|
|
@@ -105,11 +103,17 @@ module EmailSpec
|
|
|
105
103
|
url
|
|
106
104
|
end
|
|
107
105
|
|
|
106
|
+
def request_uri(link)
|
|
107
|
+
return unless link
|
|
108
|
+
url = URI::parse(link)
|
|
109
|
+
url.fragment ? (url.request_uri + "#" + url.fragment) : url.request_uri
|
|
110
|
+
end
|
|
111
|
+
|
|
108
112
|
# e.g. confirm in http://confirm
|
|
109
113
|
def parse_email_for_explicit_link(email, regex)
|
|
110
114
|
regex = /#{Regexp.escape(regex)}/ unless regex.is_a?(Regexp)
|
|
111
115
|
url = links_in_email(email).detect { |link| link =~ regex }
|
|
112
|
-
|
|
116
|
+
request_uri(url)
|
|
113
117
|
end
|
|
114
118
|
|
|
115
119
|
# e.g. Click here in <a href="http://confirm">Click here</a>
|
data/lib/email_spec.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
unless defined?(Pony) or defined?(ActionMailer)
|
|
2
2
|
Kernel.warn("Neither Pony nor ActionMailer appear to be loaded so email-spec is requiring ActionMailer.")
|
|
3
|
-
require '
|
|
3
|
+
require 'action_mailer'
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
|
@@ -57,7 +57,7 @@ Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amou
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
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)
|
|
60
|
+
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size.should == parse_email_count(amount)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
|
@@ -18,4 +18,119 @@ describe EmailSpec::Helpers do
|
|
|
18
18
|
lambda { parse_email_for_link(email, "non-existent text") }.should raise_error( RSpec::Expectations::ExpectationNotMetError)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
describe "#set_current_email" do
|
|
23
|
+
it "should cope with a nil email" do
|
|
24
|
+
lambda do
|
|
25
|
+
out = set_current_email(nil)
|
|
26
|
+
out.should be_nil
|
|
27
|
+
email_spec_hash[:current_email].should be_nil
|
|
28
|
+
end.should_not raise_error
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should cope with a real email" do
|
|
32
|
+
email = Mail.new
|
|
33
|
+
lambda do
|
|
34
|
+
out = set_current_email(email)
|
|
35
|
+
out.should == email
|
|
36
|
+
email_spec_hash[:current_email].should == email
|
|
37
|
+
end.should_not raise_error
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
shared_examples_for 'something that sets the current email for recipients' do
|
|
41
|
+
before do
|
|
42
|
+
@email = Mail.new(@recipient_type => 'dave@example.com')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should record that the email has been read for that recipient" do
|
|
46
|
+
set_current_email(@email)
|
|
47
|
+
email_spec_hash[:read_emails]['dave@example.com'].should include(@email)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should record that the email has been read for all the recipient of that type" do
|
|
51
|
+
@email.send(@recipient_type) << 'dave_2@example.com'
|
|
52
|
+
set_current_email(@email)
|
|
53
|
+
email_spec_hash[:read_emails]['dave@example.com'].should include(@email)
|
|
54
|
+
email_spec_hash[:read_emails]['dave_2@example.com'].should include(@email)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should record that the email is the current email for the recipient" do
|
|
58
|
+
set_current_email(@email)
|
|
59
|
+
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should record that the email is the current email for all the recipients of that type" do
|
|
63
|
+
@email.send(@recipient_type) << 'dave_2@example.com'
|
|
64
|
+
set_current_email(@email)
|
|
65
|
+
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
66
|
+
email_spec_hash[:current_emails]['dave_2@example.com'].should == @email
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should overwrite current email for the recipient with this one" do
|
|
70
|
+
other_mail = Mail.new
|
|
71
|
+
email_spec_hash[:current_emails]['dave@example.com'] = other_mail
|
|
72
|
+
set_current_email(@email)
|
|
73
|
+
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should overwrite the current email for all the recipients of that type" do
|
|
77
|
+
other_mail = Mail.new
|
|
78
|
+
email_spec_hash[:current_emails]['dave@example.com'] = other_mail
|
|
79
|
+
email_spec_hash[:current_emails]['dave_2@example.com'] = other_mail
|
|
80
|
+
@email.send(@recipient_type) << 'dave_2@example.com'
|
|
81
|
+
set_current_email(@email)
|
|
82
|
+
email_spec_hash[:current_emails]['dave@example.com'].should == @email
|
|
83
|
+
email_spec_hash[:current_emails]['dave_2@example.com'].should == @email
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should not complain when the email has recipients of that type" do
|
|
87
|
+
@email.send(:"#{@recipient_type}=", nil)
|
|
88
|
+
lambda { set_current_email(@email) }.should_not raise_error
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe "#request_uri(link)" do
|
|
93
|
+
context "without query and anchor" do
|
|
94
|
+
it "returns the path" do
|
|
95
|
+
request_uri('http://www.path.se/to/page').should == '/to/page'
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
context "with query and anchor" do
|
|
100
|
+
it "returns the path and query and the anchor" do
|
|
101
|
+
request_uri('http://www.path.se/to/page?q=adam#task').should == '/to/page?q=adam#task'
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
context "with anchor" do
|
|
106
|
+
it "returns the path and query and the anchor" do
|
|
107
|
+
request_uri('http://www.path.se/to/page#task').should == '/to/page#task'
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
describe 'for mails with recipients in the to address' do
|
|
113
|
+
before do
|
|
114
|
+
@recipient_type = :to
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it_should_behave_like 'something that sets the current email for recipients'
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
describe 'for mails with recipients in the cc address' do
|
|
121
|
+
before do
|
|
122
|
+
@recipient_type = :cc
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it_should_behave_like 'something that sets the current email for recipients'
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe 'for mails with recipients in the bcc address' do
|
|
129
|
+
before do
|
|
130
|
+
@recipient_type = :bcc
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it_should_behave_like 'something that sets the current email for recipients'
|
|
134
|
+
end
|
|
135
|
+
end
|
|
21
136
|
end
|
metadata
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: email_spec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
hash: 17
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 1
|
|
8
|
+
- 1
|
|
9
|
+
- 1
|
|
10
|
+
version: 1.1.1
|
|
6
11
|
platform: ruby
|
|
7
12
|
authors:
|
|
8
13
|
- Ben Mabey
|
|
@@ -12,7 +17,8 @@ autorequire:
|
|
|
12
17
|
bindir: bin
|
|
13
18
|
cert_chain: []
|
|
14
19
|
|
|
15
|
-
date:
|
|
20
|
+
date: 2010-12-29 00:00:00 -07:00
|
|
21
|
+
default_executable:
|
|
16
22
|
dependencies:
|
|
17
23
|
- !ruby/object:Gem::Dependency
|
|
18
24
|
name: rspec
|
|
@@ -22,7 +28,11 @@ dependencies:
|
|
|
22
28
|
requirements:
|
|
23
29
|
- - ~>
|
|
24
30
|
- !ruby/object:Gem::Version
|
|
25
|
-
|
|
31
|
+
hash: 3
|
|
32
|
+
segments:
|
|
33
|
+
- 2
|
|
34
|
+
- 0
|
|
35
|
+
version: "2.0"
|
|
26
36
|
type: :runtime
|
|
27
37
|
version_requirements: *id001
|
|
28
38
|
description: Easily test email in rspec and cucumber
|
|
@@ -140,6 +150,7 @@ files:
|
|
|
140
150
|
- examples/sinatra_root/features/support/env.rb
|
|
141
151
|
- examples/sinatra_root/features/support/paths.rb
|
|
142
152
|
- examples/sinatra_root/lib/example_sinatra_app.rb
|
|
153
|
+
has_rdoc: true
|
|
143
154
|
homepage: http://github.com/bmabey/email-spec/
|
|
144
155
|
licenses: []
|
|
145
156
|
|
|
@@ -153,17 +164,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
153
164
|
requirements:
|
|
154
165
|
- - ">="
|
|
155
166
|
- !ruby/object:Gem::Version
|
|
167
|
+
hash: 3
|
|
168
|
+
segments:
|
|
169
|
+
- 0
|
|
156
170
|
version: "0"
|
|
157
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
172
|
none: false
|
|
159
173
|
requirements:
|
|
160
174
|
- - ">="
|
|
161
175
|
- !ruby/object:Gem::Version
|
|
176
|
+
hash: 3
|
|
177
|
+
segments:
|
|
178
|
+
- 0
|
|
162
179
|
version: "0"
|
|
163
180
|
requirements: []
|
|
164
181
|
|
|
165
182
|
rubyforge_project: email-spec
|
|
166
|
-
rubygems_version: 1.
|
|
183
|
+
rubygems_version: 1.3.7
|
|
167
184
|
signing_key:
|
|
168
185
|
specification_version: 3
|
|
169
186
|
summary: Easily test email in rspec and cucumber
|