email_spec 2.0.0 → 2.1.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.
- checksums.yaml +13 -5
- data/Changelog.md +346 -0
- data/README.md +11 -33
- data/examples/rails4_root/db/test.sqlite3 +0 -0
- data/examples/rails4_root/features/step_definitions/email_steps.rb +17 -1
- data/examples/rails4_root/log/development.log +9 -0
- data/examples/rails4_root/log/test.log +24954 -0
- data/examples/rails4_root/spec/models/user_mailer_spec.rb +12 -6
- data/examples/sinatra_root/features/step_definitions/email_steps.rb +17 -1
- data/features/rails4_app.feature +1 -1
- data/lib/email_spec/helpers.rb +5 -2
- data/lib/email_spec/mail_ext.rb +5 -1
- data/lib/email_spec/rspec.rb +8 -0
- data/lib/email_spec/version.rb +1 -1
- data/lib/generators/email_spec/steps/templates/email_steps.rb +16 -0
- data/spec/email_spec/helpers_spec.rb +3 -1
- data/spec/email_spec/mail_ext_spec.rb +23 -0
- data/spec/email_spec/matchers_spec.rb +7 -0
- metadata +34 -47
- data/History.txt +0 -297
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
# These two example groups are specifying the exact same behavior. However, the documentation style is different
|
4
|
-
# and the value that each one provides is different with various trade-offs. Run these examples with the specdoc
|
4
|
+
# and the value that each one provides is different with various trade-offs. Run these examples with the specdoc
|
5
5
|
# formatter to get an idea of how they differ.
|
6
6
|
# Example of documenting the behaviour explicitly and expressing the intent in the example's sentence.
|
7
7
|
describe "Signup Email", :type => :model do
|
@@ -10,11 +10,11 @@ describe "Signup Email", :type => :model do
|
|
10
10
|
include ::Rails.application.routes.url_helpers
|
11
11
|
|
12
12
|
subject { UserMailer.signup("jojo@yahoo.com", "Jojo Binks") }
|
13
|
-
|
13
|
+
|
14
14
|
it "should be delivered to the email passed in" do
|
15
15
|
is_expected.to deliver_to("jojo@yahoo.com")
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should contain the user's name in the mail body" do
|
19
19
|
is_expected.to have_body_text(/Jojo Binks/)
|
20
20
|
end
|
@@ -22,10 +22,8 @@ describe "Signup Email", :type => :model do
|
|
22
22
|
it "should contain a link to the confirmation page" do
|
23
23
|
is_expected.to have_body_text(/#{confirm_account_url(:host => 'example.com')}/)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it { is_expected.to have_subject(/Account confirmation/) }
|
27
|
-
|
28
|
-
|
29
27
|
end
|
30
28
|
|
31
29
|
# In this example group more of the documentation is placed in the context trying to allow for more concise specs.
|
@@ -44,4 +42,12 @@ describe "Signup Email", :type => :model do
|
|
44
42
|
it { is_expected.to deliver_to("jojo@yahoo.com") }
|
45
43
|
it { is_expected.to have_body_text(/Jojo Binks/) }
|
46
44
|
end
|
45
|
+
|
46
|
+
describe "sent with email address of 'jermain@yahoo.com', and users name 'Jermain O'Keefe'" do
|
47
|
+
let(:user_name) { "Jermain O'Keefe" }
|
48
|
+
subject { UserMailer.signup("jermain@yahoo.com", user_name) }
|
49
|
+
|
50
|
+
it { is_expected.to deliver_to("jermain@yahoo.com") }
|
51
|
+
it { is_expected.to have_body_text(user_name) }
|
52
|
+
end
|
47
53
|
end
|
@@ -105,20 +105,36 @@ Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
|
105
105
|
expect(current_email).to have_subject(Regexp.new(text))
|
106
106
|
end
|
107
107
|
|
108
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email subject$/ do |text|
|
109
|
+
expect(current_email).not_to have_subject(text)
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email subject$/ do |text|
|
113
|
+
expect(current_email).not_to have_subject(Regexp.new(text))
|
114
|
+
end
|
115
|
+
|
108
116
|
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
109
117
|
expect(current_email.default_part_body.to_s).to include(text)
|
110
118
|
end
|
111
119
|
|
120
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email body$/ do |text|
|
121
|
+
expect(current_email.default_part_body.to_s).not_to include(text)
|
122
|
+
end
|
123
|
+
|
112
124
|
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
113
125
|
expect(current_email.default_part_body.to_s).to match Regexp.new(text)
|
114
126
|
end
|
115
127
|
|
128
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email body$/ do |text|
|
129
|
+
expect(current_email.default_part_body.to_s).not_to match Regexp.new(text)
|
130
|
+
end
|
131
|
+
|
116
132
|
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
117
133
|
expect(current_email).to be_delivered_from(text)
|
118
134
|
end
|
119
135
|
|
120
136
|
Then /^(?:I|they) should see the email reply to "([^"]*?)"$/ do |text|
|
121
|
-
current_email.
|
137
|
+
expect(current_email).to have_reply_to(text)
|
122
138
|
end
|
123
139
|
|
124
140
|
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
data/features/rails4_app.feature
CHANGED
@@ -22,7 +22,7 @@ I want to verify that the example rails 4 app runs all of it's features as expec
|
|
22
22
|
When I run "bundle exec rake spec RAILS_ENV=test" in the rails4 app
|
23
23
|
Then I should see the following summary report:
|
24
24
|
"""
|
25
|
-
|
25
|
+
11 examples, 0 failures
|
26
26
|
"""
|
27
27
|
|
28
28
|
When I run "bundle exec rake test RAILS_ENV=test" in the rails4 app
|
data/lib/email_spec/helpers.rb
CHANGED
@@ -6,6 +6,9 @@ module EmailSpec
|
|
6
6
|
module Helpers
|
7
7
|
include Deliveries
|
8
8
|
|
9
|
+
A_TAG_BEGIN_REGEX = %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*>(?:(?!</a>).)*?}
|
10
|
+
A_TAG_END_REGEX = %r{(?:(?!</a>).)*?</a>}
|
11
|
+
|
9
12
|
def visit_in_email(link_text, address = '')
|
10
13
|
if address.nil? || address.empty?
|
11
14
|
email = current_email
|
@@ -97,7 +100,7 @@ module EmailSpec
|
|
97
100
|
if current_email_address.nil?
|
98
101
|
raise EmailSpec::NoEmailAddressProvided, "No email address has been provided. Make sure current_email_address is returning something."
|
99
102
|
elsif email.nil?
|
100
|
-
error = "#{opts.keys.first.to_s.
|
103
|
+
error = "#{opts.keys.first.to_s.gsub("_", " ").downcase unless opts.empty?} #{('"' + opts.values.first.to_s + '"') unless opts.empty?}"
|
101
104
|
raise EmailSpec::CouldNotFindEmailError, "Could not find email #{error} in the mailbox for #{current_email_address}. \n Found the following emails:\n\n #{all_emails.to_s}"
|
102
105
|
end
|
103
106
|
email
|
@@ -142,7 +145,7 @@ module EmailSpec
|
|
142
145
|
|
143
146
|
# e.g. Click here in <a href="http://confirm">Click here</a>
|
144
147
|
def parse_email_for_anchor_text_link(email, link_text)
|
145
|
-
if textify_images(email.default_part_body) =~ %r{
|
148
|
+
if textify_images(email.default_part_body) =~ %r{#{A_TAG_BEGIN_REGEX}#{link_text}#{A_TAG_END_REGEX}}
|
146
149
|
URI.split($1)[5..-1].compact!.join("?").gsub("&", "&")
|
147
150
|
# sub correct ampersand after rails switches it (http://dev.rubyonrails.org/ticket/4002)
|
148
151
|
else
|
data/lib/email_spec/mail_ext.rb
CHANGED
data/lib/email_spec/version.rb
CHANGED
@@ -105,14 +105,30 @@ Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
|
105
105
|
expect(current_email).to have_subject(Regexp.new(text))
|
106
106
|
end
|
107
107
|
|
108
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email subject$/ do |text|
|
109
|
+
expect(current_email).not_to have_subject(text)
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email subject$/ do |text|
|
113
|
+
expect(current_email).not_to have_subject(Regexp.new(text))
|
114
|
+
end
|
115
|
+
|
108
116
|
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
109
117
|
expect(current_email.default_part_body.to_s).to include(text)
|
110
118
|
end
|
111
119
|
|
120
|
+
Then /^(?:I|they) should not see "([^"]*?)" in the email body$/ do |text|
|
121
|
+
expect(current_email.default_part_body.to_s).not_to include(text)
|
122
|
+
end
|
123
|
+
|
112
124
|
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
113
125
|
expect(current_email.default_part_body.to_s).to match Regexp.new(text)
|
114
126
|
end
|
115
127
|
|
128
|
+
Then /^(?:I|they) should not see \/([^"]*?)\/ in the email body$/ do |text|
|
129
|
+
expect(current_email.default_part_body.to_s).not_to match Regexp.new(text)
|
130
|
+
end
|
131
|
+
|
116
132
|
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
117
133
|
expect(current_email).to be_delivered_from(text)
|
118
134
|
end
|
@@ -31,7 +31,9 @@ describe EmailSpec::Helpers do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "properly finds links with text surrounded by tags" do
|
34
|
-
email = Mail.new(:body => %(
|
34
|
+
email = Mail.new(:body => %(
|
35
|
+
<a href="/path/to/app">Welcome</a><a href="/path/to/page"><strong>Click Here</strong></a>))
|
36
|
+
|
35
37
|
expect(parse_email_for_link(email, "Click Here")).to eq("/path/to/page")
|
36
38
|
end
|
37
39
|
|
@@ -31,4 +31,27 @@ describe EmailSpec::MailExt do
|
|
31
31
|
expect(email.default_part.body).to eq(email.default_part_body)
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
describe "#html" do
|
36
|
+
it "returns the html part body" do
|
37
|
+
email = Mail.new do
|
38
|
+
html_part { body "This is html" }
|
39
|
+
end
|
40
|
+
|
41
|
+
expect(email.html).to eq("This is html")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns a String" do
|
45
|
+
email = Mail.new do
|
46
|
+
html_part { body "This is html" }
|
47
|
+
end
|
48
|
+
|
49
|
+
expect(email.html).to be_a(String)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns nil for mail with no html part" do
|
53
|
+
email = Mail.new
|
54
|
+
expect(email.html).to be_nil
|
55
|
+
end
|
56
|
+
end
|
34
57
|
end
|
@@ -402,6 +402,13 @@ describe EmailSpec::Matchers do
|
|
402
402
|
end
|
403
403
|
|
404
404
|
describe "when strings are used" do
|
405
|
+
it "should match when the body includes text with symbols" do
|
406
|
+
full_name = "Jermain O'Keefe"
|
407
|
+
email = Mail::Message.new(body: full_name)
|
408
|
+
|
409
|
+
expect(have_body_text(full_name)).to match(email)
|
410
|
+
end
|
411
|
+
|
405
412
|
it "should match when the body includes the text" do
|
406
413
|
email = Mail::Message.new(:body => 'foo bar baz')
|
407
414
|
|
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: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Mabey
|
@@ -10,174 +10,160 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: htmlentities
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 4.3.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 4.3.3
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: launchy
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '2.1'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '2.1'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: mail
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 2.6.3
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ~>
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 2.6.3
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rake
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ! '>='
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: 0.8.7
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ! '>='
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 0.8.7
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: cucumber
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.3.17
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ~>
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: 1.3.17
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
86
|
+
name: actionmailer
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ~>
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
91
|
+
version: '4.2'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ~>
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
name: cucumber-sinatra
|
101
|
-
requirement: !ruby/object:Gem::Requirement
|
102
|
-
requirements:
|
103
|
-
- - "~>"
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: 0.5.0
|
106
|
-
type: :development
|
107
|
-
prerelease: false
|
108
|
-
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
requirements:
|
110
|
-
- - "~>"
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 0.5.0
|
98
|
+
version: '4.2'
|
113
99
|
- !ruby/object:Gem::Dependency
|
114
100
|
name: rack-test
|
115
101
|
requirement: !ruby/object:Gem::Requirement
|
116
102
|
requirements:
|
117
|
-
- -
|
103
|
+
- - ! '>='
|
118
104
|
- !ruby/object:Gem::Version
|
119
105
|
version: '0'
|
120
106
|
type: :development
|
121
107
|
prerelease: false
|
122
108
|
version_requirements: !ruby/object:Gem::Requirement
|
123
109
|
requirements:
|
124
|
-
- -
|
110
|
+
- - ! '>='
|
125
111
|
- !ruby/object:Gem::Version
|
126
112
|
version: '0'
|
127
113
|
- !ruby/object:Gem::Dependency
|
128
114
|
name: rspec
|
129
115
|
requirement: !ruby/object:Gem::Requirement
|
130
116
|
requirements:
|
131
|
-
- -
|
117
|
+
- - ~>
|
132
118
|
- !ruby/object:Gem::Version
|
133
119
|
version: '3.1'
|
134
120
|
type: :development
|
135
121
|
prerelease: false
|
136
122
|
version_requirements: !ruby/object:Gem::Requirement
|
137
123
|
requirements:
|
138
|
-
- -
|
124
|
+
- - ~>
|
139
125
|
- !ruby/object:Gem::Version
|
140
126
|
version: '3.1'
|
141
127
|
- !ruby/object:Gem::Dependency
|
142
128
|
name: capybara
|
143
129
|
requirement: !ruby/object:Gem::Requirement
|
144
130
|
requirements:
|
145
|
-
- -
|
131
|
+
- - ! '>='
|
146
132
|
- !ruby/object:Gem::Version
|
147
133
|
version: '0'
|
148
134
|
type: :development
|
149
135
|
prerelease: false
|
150
136
|
version_requirements: !ruby/object:Gem::Requirement
|
151
137
|
requirements:
|
152
|
-
- -
|
138
|
+
- - ! '>='
|
153
139
|
- !ruby/object:Gem::Version
|
154
140
|
version: '0'
|
155
141
|
- !ruby/object:Gem::Dependency
|
156
142
|
name: database_cleaner
|
157
143
|
requirement: !ruby/object:Gem::Requirement
|
158
144
|
requirements:
|
159
|
-
- -
|
145
|
+
- - ! '>='
|
160
146
|
- !ruby/object:Gem::Version
|
161
147
|
version: '0'
|
162
148
|
type: :development
|
163
149
|
prerelease: false
|
164
150
|
version_requirements: !ruby/object:Gem::Requirement
|
165
151
|
requirements:
|
166
|
-
- -
|
152
|
+
- - ! '>='
|
167
153
|
- !ruby/object:Gem::Version
|
168
154
|
version: '0'
|
169
155
|
- !ruby/object:Gem::Dependency
|
170
156
|
name: test-unit
|
171
157
|
requirement: !ruby/object:Gem::Requirement
|
172
158
|
requirements:
|
173
|
-
- -
|
159
|
+
- - ! '>='
|
174
160
|
- !ruby/object:Gem::Version
|
175
161
|
version: '0'
|
176
162
|
type: :development
|
177
163
|
prerelease: false
|
178
164
|
version_requirements: !ruby/object:Gem::Requirement
|
179
165
|
requirements:
|
180
|
-
- -
|
166
|
+
- - ! '>='
|
181
167
|
- !ruby/object:Gem::Version
|
182
168
|
version: '0'
|
183
169
|
description: Easily test email in RSpec, Cucumber, and MiniTest
|
@@ -188,7 +174,7 @@ extra_rdoc_files:
|
|
188
174
|
- README.md
|
189
175
|
- MIT-LICENSE.txt
|
190
176
|
files:
|
191
|
-
-
|
177
|
+
- Changelog.md
|
192
178
|
- MIT-LICENSE.txt
|
193
179
|
- README.md
|
194
180
|
- Rakefile
|
@@ -302,6 +288,7 @@ files:
|
|
302
288
|
- lib/email_spec/helpers.rb
|
303
289
|
- lib/email_spec/mail_ext.rb
|
304
290
|
- lib/email_spec/matchers.rb
|
291
|
+
- lib/email_spec/rspec.rb
|
305
292
|
- lib/email_spec/test_observer.rb
|
306
293
|
- lib/email_spec/version.rb
|
307
294
|
- lib/generators/email_spec/steps/steps_generator.rb
|
@@ -311,7 +298,7 @@ files:
|
|
311
298
|
- spec/email_spec/mail_ext_spec.rb
|
312
299
|
- spec/email_spec/matchers_spec.rb
|
313
300
|
- spec/spec_helper.rb
|
314
|
-
homepage: http://github.com/
|
301
|
+
homepage: http://github.com/email-spec/email-spec/
|
315
302
|
licenses:
|
316
303
|
- MIT
|
317
304
|
metadata: {}
|
@@ -321,18 +308,18 @@ require_paths:
|
|
321
308
|
- lib
|
322
309
|
required_ruby_version: !ruby/object:Gem::Requirement
|
323
310
|
requirements:
|
324
|
-
- -
|
311
|
+
- - ! '>='
|
325
312
|
- !ruby/object:Gem::Version
|
326
313
|
version: '0'
|
327
314
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
328
315
|
requirements:
|
329
|
-
- -
|
316
|
+
- - ! '>='
|
330
317
|
- !ruby/object:Gem::Version
|
331
318
|
version: '0'
|
332
319
|
requirements: []
|
333
320
|
rubyforge_project: email-spec
|
334
|
-
rubygems_version: 2.4.
|
321
|
+
rubygems_version: 2.4.8
|
335
322
|
signing_key:
|
336
323
|
specification_version: 4
|
337
|
-
summary: Easily test email in
|
324
|
+
summary: Easily test email in RSpec, Cucumber or Minitest
|
338
325
|
test_files: []
|