email_spec 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Changelog.md +10 -0
- data/README.md +1 -1
- data/examples/rails4_root/Gemfile +1 -1
- data/examples/rails4_root/Gemfile.lock +104 -95
- data/examples/rails4_root/db/schema.rb +2 -2
- data/examples/rails4_root/db/test.sqlite3 +0 -0
- data/examples/rails4_root/log/development.log +0 -9
- data/examples/rails4_root/log/test.log +713 -66414
- data/examples/sinatra_root/Gemfile.lock +50 -42
- data/lib/email_spec/email_viewer.rb +1 -1
- data/lib/email_spec/helpers.rb +4 -4
- data/lib/email_spec/version.rb +1 -1
- data/spec/email_spec/helpers_spec.rb +14 -0
- metadata +29 -31
- data/examples/rails4_root/vendor/plugins/email_spec/rails_generators/email_spec/email_spec_generator.rb +0 -17
- data/examples/rails4_root/vendor/plugins/email_spec/rails_generators/email_spec/templates/email_steps.rb +0 -199
@@ -1,78 +1,86 @@
|
|
1
1
|
PATH
|
2
|
-
remote:
|
2
|
+
remote: ../..
|
3
3
|
specs:
|
4
|
-
email_spec (2.
|
4
|
+
email_spec (2.1.0)
|
5
5
|
htmlentities (~> 4.3.3)
|
6
6
|
launchy (~> 2.1)
|
7
|
-
mail (~> 2.6
|
7
|
+
mail (~> 2.6)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
addressable (2.
|
13
|
-
|
14
|
-
|
12
|
+
addressable (2.5.1)
|
13
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
14
|
+
builder (3.2.3)
|
15
|
+
capybara (2.14.0)
|
16
|
+
addressable
|
15
17
|
mime-types (>= 1.16)
|
16
18
|
nokogiri (>= 1.3.3)
|
17
19
|
rack (>= 1.0.0)
|
18
20
|
rack-test (>= 0.5.4)
|
19
21
|
xpath (~> 2.0)
|
20
|
-
cucumber (2.
|
22
|
+
cucumber (2.4.0)
|
21
23
|
builder (>= 2.1.2)
|
22
|
-
cucumber-core (~> 1.
|
24
|
+
cucumber-core (~> 1.5.0)
|
25
|
+
cucumber-wire (~> 0.0.1)
|
23
26
|
diff-lcs (>= 1.1.3)
|
24
|
-
gherkin (~>
|
27
|
+
gherkin (~> 4.0)
|
25
28
|
multi_json (>= 1.7.5, < 2.0)
|
26
29
|
multi_test (>= 0.1.2)
|
27
|
-
cucumber-core (1.
|
28
|
-
gherkin (~>
|
30
|
+
cucumber-core (1.5.0)
|
31
|
+
gherkin (~> 4.0)
|
29
32
|
cucumber-sinatra (0.5.0)
|
30
33
|
templater (>= 1.0.0)
|
31
|
-
|
34
|
+
cucumber-wire (0.0.1)
|
35
|
+
diff-lcs (1.3)
|
32
36
|
extlib (0.9.16)
|
33
|
-
gherkin (
|
34
|
-
|
35
|
-
|
36
|
-
htmlentities (4.3.3)
|
37
|
+
gherkin (4.1.3)
|
38
|
+
highline (1.7.8)
|
39
|
+
htmlentities (4.3.4)
|
37
40
|
launchy (2.4.3)
|
38
41
|
addressable (~> 2.3)
|
39
|
-
mail (2.6.
|
40
|
-
mime-types (>= 1.16, <
|
41
|
-
mime-types (
|
42
|
-
|
43
|
-
|
42
|
+
mail (2.6.5)
|
43
|
+
mime-types (>= 1.16, < 4)
|
44
|
+
mime-types (3.1)
|
45
|
+
mime-types-data (~> 3.2015)
|
46
|
+
mime-types-data (3.2016.0521)
|
47
|
+
mini_portile2 (2.1.0)
|
48
|
+
multi_json (1.12.1)
|
44
49
|
multi_test (0.1.2)
|
45
|
-
|
46
|
-
|
50
|
+
mustermann (1.0.0)
|
51
|
+
nokogiri (1.7.2)
|
52
|
+
mini_portile2 (~> 2.1.0)
|
47
53
|
pony (1.11)
|
48
54
|
mail (>= 2.0)
|
49
|
-
|
50
|
-
rack
|
55
|
+
public_suffix (2.0.5)
|
56
|
+
rack (2.0.3)
|
57
|
+
rack-protection (2.0.0)
|
51
58
|
rack
|
52
59
|
rack-test (0.6.3)
|
53
60
|
rack (>= 1.0)
|
54
|
-
rspec (3.
|
55
|
-
rspec-core (~> 3.
|
56
|
-
rspec-expectations (~> 3.
|
57
|
-
rspec-mocks (~> 3.
|
58
|
-
rspec-core (3.
|
59
|
-
rspec-support (~> 3.
|
60
|
-
rspec-expectations (3.
|
61
|
+
rspec (3.6.0)
|
62
|
+
rspec-core (~> 3.6.0)
|
63
|
+
rspec-expectations (~> 3.6.0)
|
64
|
+
rspec-mocks (~> 3.6.0)
|
65
|
+
rspec-core (3.6.0)
|
66
|
+
rspec-support (~> 3.6.0)
|
67
|
+
rspec-expectations (3.6.0)
|
61
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
-
rspec-support (~> 3.
|
63
|
-
rspec-mocks (3.
|
69
|
+
rspec-support (~> 3.6.0)
|
70
|
+
rspec-mocks (3.6.0)
|
64
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-support (3.
|
67
|
-
sinatra (
|
68
|
-
|
69
|
-
rack
|
70
|
-
|
72
|
+
rspec-support (~> 3.6.0)
|
73
|
+
rspec-support (3.6.0)
|
74
|
+
sinatra (2.0.0)
|
75
|
+
mustermann (~> 1.0)
|
76
|
+
rack (~> 2.0)
|
77
|
+
rack-protection (= 2.0.0)
|
78
|
+
tilt (~> 2.0)
|
71
79
|
templater (1.0.0)
|
72
80
|
diff-lcs (>= 1.1.2)
|
73
81
|
extlib (>= 0.9.5)
|
74
82
|
highline (>= 1.4.0)
|
75
|
-
tilt (2.0.
|
83
|
+
tilt (2.0.7)
|
76
84
|
xpath (2.0.0)
|
77
85
|
nokogiri (~> 1.3)
|
78
86
|
|
@@ -92,4 +100,4 @@ DEPENDENCIES
|
|
92
100
|
xpath
|
93
101
|
|
94
102
|
BUNDLED WITH
|
95
|
-
1.
|
103
|
+
1.14.6
|
@@ -17,7 +17,7 @@ module EmailSpec
|
|
17
17
|
|
18
18
|
def self.save_and_open_all_html_emails
|
19
19
|
all_emails.each_with_index do |m, index|
|
20
|
-
if m.multipart? &&
|
20
|
+
if m.multipart? && m.parts.detect{ |p| p.content_type.include?('text/html') }
|
21
21
|
filename = tmp_email_filename("-#{index}.html")
|
22
22
|
File.open(filename, "w") do |f|
|
23
23
|
f.write m.parts[1].body
|
data/lib/email_spec/helpers.rb
CHANGED
@@ -6,8 +6,8 @@ module EmailSpec
|
|
6
6
|
module Helpers
|
7
7
|
include Deliveries
|
8
8
|
|
9
|
-
A_TAG_BEGIN_REGEX = %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]
|
10
|
-
A_TAG_END_REGEX = %r{(?:(?!</a>).)
|
9
|
+
A_TAG_BEGIN_REGEX = %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*>\s*(?:(?!</a>).)*?\s*}
|
10
|
+
A_TAG_END_REGEX = %r{\s*(?:(?!</a>).)*?\s*</a>}
|
11
11
|
|
12
12
|
def visit_in_email(link_text, address = '')
|
13
13
|
if address.nil? || address.empty?
|
@@ -85,7 +85,7 @@ module EmailSpec
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def links_in_email(email)
|
88
|
-
links = URI.extract(email.default_part_body.to_s, ['http', 'https'])
|
88
|
+
links = URI::Parser.new.extract(email.default_part_body.to_s, ['http', 'https'])
|
89
89
|
links.map{|url| HTMLEntities.new.decode(url) }.uniq
|
90
90
|
end
|
91
91
|
|
@@ -102,7 +102,7 @@ module EmailSpec
|
|
102
102
|
elsif email.nil?
|
103
103
|
error = "#{opts.keys.first.to_s.gsub("_", " ").downcase unless opts.empty?} #{('"' + opts.values.first.to_s + '"') unless opts.empty?}"
|
104
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}"
|
105
|
-
|
105
|
+
end
|
106
106
|
email
|
107
107
|
end
|
108
108
|
|
data/lib/email_spec/version.rb
CHANGED
@@ -37,6 +37,20 @@ describe EmailSpec::Helpers do
|
|
37
37
|
expect(parse_email_for_link(email, "Click Here")).to eq("/path/to/page")
|
38
38
|
end
|
39
39
|
|
40
|
+
it "properly finds links with tags and text in new lines" do
|
41
|
+
email = Mail.new(:body => <<-HTML
|
42
|
+
<a href="/path/to/app">Welcome</a>
|
43
|
+
<a href="/path/to/page">
|
44
|
+
<strong>
|
45
|
+
Click Here
|
46
|
+
</strong>
|
47
|
+
</a>
|
48
|
+
HTML
|
49
|
+
)
|
50
|
+
|
51
|
+
expect(parse_email_for_link(email, "Click Here")).to eq("/path/to/page")
|
52
|
+
end
|
53
|
+
|
40
54
|
it "recognizes img alt properties as text" do
|
41
55
|
email = Mail.new(:body => %(<a href="/path/to/page"><img src="http://host.com/images/image.gif" alt="an image" /></a>))
|
42
56
|
expect(parse_email_for_link(email, "an image")).to eq("/path/to/page")
|
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.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Mabey
|
@@ -10,160 +10,160 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-05-16 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
|
-
version: 2.6
|
49
|
+
version: '2.6'
|
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
|
-
version: 2.6
|
56
|
+
version: '2.6'
|
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
86
|
name: actionmailer
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - ~>
|
89
|
+
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
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
98
|
version: '4.2'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: rack-test
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rspec
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- - ~>
|
117
|
+
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '3.1'
|
120
120
|
type: :development
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- - ~>
|
124
|
+
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '3.1'
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: capybara
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- -
|
138
|
+
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: database_cleaner
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- -
|
145
|
+
- - ">="
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
type: :development
|
149
149
|
prerelease: false
|
150
150
|
version_requirements: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- -
|
152
|
+
- - ">="
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
- !ruby/object:Gem::Dependency
|
156
156
|
name: test-unit
|
157
157
|
requirement: !ruby/object:Gem::Requirement
|
158
158
|
requirements:
|
159
|
-
- -
|
159
|
+
- - ">="
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '0'
|
162
162
|
type: :development
|
163
163
|
prerelease: false
|
164
164
|
version_requirements: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
|
-
- -
|
166
|
+
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
description: Easily test email in RSpec, Cucumber, and MiniTest
|
@@ -261,8 +261,6 @@ files:
|
|
261
261
|
- examples/rails4_root/test/mailers/user_mailer_classic_test.rb
|
262
262
|
- examples/rails4_root/test/mailers/user_mailer_spec_test.rb
|
263
263
|
- examples/rails4_root/test/test_helper.rb
|
264
|
-
- examples/rails4_root/vendor/plugins/email_spec/rails_generators/email_spec/email_spec_generator.rb
|
265
|
-
- examples/rails4_root/vendor/plugins/email_spec/rails_generators/email_spec/templates/email_steps.rb
|
266
264
|
- examples/sinatra_root/Gemfile
|
267
265
|
- examples/sinatra_root/Gemfile.lock
|
268
266
|
- examples/sinatra_root/config.ru
|
@@ -308,17 +306,17 @@ require_paths:
|
|
308
306
|
- lib
|
309
307
|
required_ruby_version: !ruby/object:Gem::Requirement
|
310
308
|
requirements:
|
311
|
-
- -
|
309
|
+
- - ">="
|
312
310
|
- !ruby/object:Gem::Version
|
313
311
|
version: '0'
|
314
312
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
315
313
|
requirements:
|
316
|
-
- -
|
314
|
+
- - ">="
|
317
315
|
- !ruby/object:Gem::Version
|
318
316
|
version: '0'
|
319
317
|
requirements: []
|
320
318
|
rubyforge_project: email-spec
|
321
|
-
rubygems_version: 2.
|
319
|
+
rubygems_version: 2.6.8
|
322
320
|
signing_key:
|
323
321
|
specification_version: 4
|
324
322
|
summary: Easily test email in RSpec, Cucumber or Minitest
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,199 +0,0 @@
|
|
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 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|he|she|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
52
|
-
expect(unread_emails_for(address).size).to eql parse_email_count(amount)
|
53
|
-
end
|
54
|
-
|
55
|
-
Then /^(?:I|they|he|she|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
56
|
-
expect(mailbox_for(address).size).to eql parse_email_count(amount)
|
57
|
-
end
|
58
|
-
|
59
|
-
Then /^(?:I|they|he|she|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
60
|
-
expect(unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size).to eql parse_email_count(amount)
|
61
|
-
end
|
62
|
-
|
63
|
-
Then /^(?:I|they|he|she|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
64
|
-
open_email(address, :with_text => expected_body)
|
65
|
-
end
|
66
|
-
|
67
|
-
#
|
68
|
-
# Accessing emails
|
69
|
-
#
|
70
|
-
|
71
|
-
# Opens the most recently received email
|
72
|
-
When /^(?:I|they|he|she|"([^"]*?)") opens? the email$/ do |address|
|
73
|
-
open_email(address)
|
74
|
-
end
|
75
|
-
|
76
|
-
When /^(?:I|they|he|she|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
77
|
-
open_email(address, :with_subject => subject)
|
78
|
-
end
|
79
|
-
|
80
|
-
When /^(?:I|they|he|she|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
81
|
-
open_email(address, :with_text => text)
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Inspect the Email Contents
|
86
|
-
#
|
87
|
-
|
88
|
-
Then /^(?:I|they|he|she) should see "([^"]*?)" in the email subject$/ do |text|
|
89
|
-
expect(current_email).to have_subject(text)
|
90
|
-
end
|
91
|
-
|
92
|
-
Then /^(?:I|they|he|she) should see "([^"]*?)" in the email body$/ do |text|
|
93
|
-
if current_email.multipart?
|
94
|
-
Then %(I should see "#{text}" in the html part of the email body)
|
95
|
-
Then %(I should see "#{text}" in the text part of the email body)
|
96
|
-
else
|
97
|
-
expect(current_email.body).to match Regexp.new(text)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
Then /^(?:I|they|he|she) should see "([^"]*?)" in the html part of the email body$/ do |text|
|
102
|
-
expect(current_email.html_part.body).to match Regexp.new(text)
|
103
|
-
end
|
104
|
-
|
105
|
-
Then /^(?:I|they|he|she) should see "([^"]*?)" in the text part of the email body$/ do |text|
|
106
|
-
expect(current_email.text_part.body).to match Regexp.new(text)
|
107
|
-
end
|
108
|
-
|
109
|
-
Then /^(?:I|they|he|she) should see "([^"]*?)" in the email body$/ do |text|
|
110
|
-
expect(current_email.body).to include(text)
|
111
|
-
end
|
112
|
-
|
113
|
-
Then /^(?:I|they|he|she) should see \/([^"]*?)\/ in the email body$/ do |text|
|
114
|
-
expect(current_email.body).to match Regexp.new(text)
|
115
|
-
end
|
116
|
-
|
117
|
-
Then /^(?:I|they|he|she) should see the email delivered from "([^"]*?)"$/ do |text|
|
118
|
-
expect(current_email).to be_delivered_from(text)
|
119
|
-
end
|
120
|
-
|
121
|
-
Then /^(?:I|they) should see the email reply to "([^"]*?)"$/ do |text|
|
122
|
-
current_email.should have_reply_to(text)
|
123
|
-
end
|
124
|
-
|
125
|
-
Then /^(?:I|they|he|she) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
126
|
-
expect(current_email).to have_header(name, text)
|
127
|
-
end
|
128
|
-
|
129
|
-
Then /^(?:I|they|he|she) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
130
|
-
expect(current_email).to have_header(name, Regexp.new(text))
|
131
|
-
end
|
132
|
-
|
133
|
-
#
|
134
|
-
# Inspect the Email Attachments
|
135
|
-
#
|
136
|
-
|
137
|
-
Then /^(?:I|they|he|she) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
138
|
-
expect(current_email_attachments.size).to eql parse_email_count(amount)
|
139
|
-
end
|
140
|
-
|
141
|
-
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
142
|
-
expect(current_email_attachments.select { |a| a.original_filename == filename }.size).to eql parse_email_count(amount)
|
143
|
-
end
|
144
|
-
|
145
|
-
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
146
|
-
expect(current_email_attachments[(index.to_i - 1)].original_filename).to eql filename
|
147
|
-
end
|
148
|
-
|
149
|
-
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
150
|
-
expect(current_email_attachments.select { |a| a.content_type == content_type }.size).to eql parse_email_count(amount)
|
151
|
-
end
|
152
|
-
|
153
|
-
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
154
|
-
expect(current_email_attachments[(index.to_i - 1)].content_type).to eql content_type
|
155
|
-
end
|
156
|
-
|
157
|
-
Then /^all attachments should not be blank$/ do
|
158
|
-
current_email_attachments.each do |attachment|
|
159
|
-
expect(attachment.size).to_not eql 0
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
Then /^show me a list of email attachments$/ do
|
164
|
-
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
165
|
-
end
|
166
|
-
|
167
|
-
#
|
168
|
-
# Interact with Email Contents
|
169
|
-
#
|
170
|
-
|
171
|
-
When /^(?:I|they|he|she) follow "([^"]*?)" in the email$/ do |link|
|
172
|
-
visit_in_email(link)
|
173
|
-
end
|
174
|
-
|
175
|
-
When /^(?:I|they|he|she) click the first link in the email$/ do
|
176
|
-
click_first_link_in_email
|
177
|
-
end
|
178
|
-
|
179
|
-
#
|
180
|
-
# Debugging
|
181
|
-
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
182
|
-
# Patches accepted. ;)
|
183
|
-
#
|
184
|
-
|
185
|
-
Then /^save and open current email$/ do
|
186
|
-
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
187
|
-
end
|
188
|
-
|
189
|
-
Then /^save and open all text emails$/ do
|
190
|
-
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
191
|
-
end
|
192
|
-
|
193
|
-
Then /^save and open all html emails$/ do
|
194
|
-
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
195
|
-
end
|
196
|
-
|
197
|
-
Then /^save and open all raw emails$/ do
|
198
|
-
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
199
|
-
end
|