spreewald 1.12.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -0
- data/README.md +4 -0
- data/lib/spreewald/email_steps.rb +11 -11
- data/lib/spreewald/table_steps.rb +2 -2
- data/lib/spreewald/web_steps.rb +42 -42
- data/lib/spreewald_support/mail_finder.rb +2 -1
- data/lib/spreewald_support/version.rb +1 -1
- data/lib/spreewald_support/web_steps_helpers.rb +8 -8
- data/spreewald.gemspec +1 -1
- data/tests/rails-3_capybara-1/Gemfile.lock +6 -1
- data/tests/rails-3_capybara-2/Gemfile.lock +6 -1
- data/tests/rails-4_capybara-3/Gemfile.lock +6 -1
- data/tests/rails-4_capybara-3/features/email_steps.feature +102 -11
- data/tests/rails-4_capybara-3/features/step_definitions/overriding_steps.rb +1 -1
- data/tests/rails-4_capybara-3/features/web_steps.feature +33 -3
- data/tests/shared/app/controllers/forms_controller.rb +3 -0
- data/tests/shared/app/models/mailer.rb +9 -4
- data/tests/shared/app/views/emails/send_email.haml +0 -0
- data/tests/shared/app/views/forms/form1.html.haml +4 -0
- data/tests/shared/app/views/forms/invalid_form.html.haml +10 -0
- data/tests/shared/app/views/mailer/email.haml +4 -0
- data/tests/shared/db/test.sqlite3 +0 -0
- data/tests/shared/features/shared/email_steps.feature +102 -11
- data/tests/shared/features/shared/step_definitions/overriding_steps.rb +1 -1
- data/tests/shared/features/shared/web_steps.feature +33 -3
- metadata +22 -16
@@ -44,7 +44,7 @@ class MailFinder
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def email_text_body(mail)
|
47
|
-
if mail.parts.any?
|
47
|
+
body = if mail.parts.any?
|
48
48
|
mail_bodies = mail.parts.map { |part|
|
49
49
|
if part.header.to_s.include?('Quoted-printable')
|
50
50
|
if Rails.version.starts_with?('2.3')
|
@@ -69,6 +69,7 @@ class MailFinder
|
|
69
69
|
else
|
70
70
|
mail.body
|
71
71
|
end
|
72
|
+
body.gsub("\r\n", "\n") # The mail gem (>= 2.7.1) switched from \n to \r\n line breaks (LF to CRLF) in plain text mails.
|
72
73
|
end
|
73
74
|
|
74
75
|
end
|
@@ -72,9 +72,9 @@ module WebStepsHelpers
|
|
72
72
|
end
|
73
73
|
|
74
74
|
if options[:expectation] == :visible
|
75
|
-
visible.
|
75
|
+
expect(visible).to eq(true)
|
76
76
|
else
|
77
|
-
visible.
|
77
|
+
expect(visible).to eq(false)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -86,23 +86,23 @@ module WebStepsHelpers
|
|
86
86
|
|
87
87
|
if options.has_key?(:selector)
|
88
88
|
selector = options[:selector].strip
|
89
|
-
page.
|
89
|
+
expect(page).to have_css options[:selector]
|
90
90
|
|
91
91
|
have_hidden_tag = have_css %(.hidden #{selector}, .invisible #{selector}, [style~="display: none"] #{selector})
|
92
92
|
|
93
93
|
if options[:expectation] == :hidden
|
94
|
-
page.
|
94
|
+
expect(page).to have_hidden_tag
|
95
95
|
else
|
96
|
-
page.
|
96
|
+
expect(page).not_to have_hidden_tag
|
97
97
|
end
|
98
98
|
|
99
99
|
else
|
100
|
-
page.
|
100
|
+
expect(page).to have_css('*', :text => options[:text])
|
101
101
|
have_hidden_text = have_css('.hidden, .invisible, [style~="display: none"]', :text => options[:text])
|
102
102
|
if options[:expectation] == :hidden
|
103
|
-
page.
|
103
|
+
expect(page).to have_hidden_text
|
104
104
|
else
|
105
|
-
page.
|
105
|
+
expect(page).not_to have_hidden_text
|
106
106
|
end
|
107
107
|
end
|
108
108
|
ensure
|
data/spreewald.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.add_dependency('cucumber')
|
21
21
|
gem.add_dependency('cucumber_priority', '>=0.3.0')
|
22
|
+
gem.add_dependency('rspec')
|
22
23
|
|
23
24
|
# Development
|
24
25
|
gem.add_development_dependency 'bundler', '~> 1.11'
|
@@ -27,6 +28,5 @@ Gem::Specification.new do |gem|
|
|
27
28
|
|
28
29
|
# Testing
|
29
30
|
gem.add_development_dependency 'aruba', '~> 0.10.2'
|
30
|
-
gem.add_development_dependency 'rspec', '~> 3.4.0'
|
31
31
|
gem.add_development_dependency 'geordi'
|
32
32
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
spreewald (
|
4
|
+
spreewald (2.0.0)
|
5
5
|
cucumber
|
6
6
|
cucumber_priority (>= 0.3.0)
|
7
|
+
rspec
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -110,6 +111,10 @@ GEM
|
|
110
111
|
rake (10.0.4)
|
111
112
|
rdoc (3.12.2)
|
112
113
|
json (~> 1.4)
|
114
|
+
rspec (2.13.0)
|
115
|
+
rspec-core (~> 2.13.0)
|
116
|
+
rspec-expectations (~> 2.13.0)
|
117
|
+
rspec-mocks (~> 2.13.0)
|
113
118
|
rspec-core (2.13.1)
|
114
119
|
rspec-expectations (2.13.0)
|
115
120
|
diff-lcs (>= 1.1.3, < 2.0)
|
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
spreewald (
|
4
|
+
spreewald (2.0.0)
|
5
5
|
cucumber
|
6
6
|
cucumber_priority (>= 0.3.0)
|
7
|
+
rspec
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -118,6 +119,10 @@ GEM
|
|
118
119
|
rbx-require-relative (0.0.9)
|
119
120
|
rdoc (3.12.2)
|
120
121
|
json (~> 1.4)
|
122
|
+
rspec (2.13.0)
|
123
|
+
rspec-core (~> 2.13.0)
|
124
|
+
rspec-expectations (~> 2.13.0)
|
125
|
+
rspec-mocks (~> 2.13.0)
|
121
126
|
rspec-core (2.13.1)
|
122
127
|
rspec-expectations (2.13.0)
|
123
128
|
diff-lcs (>= 1.1.3, < 2.0)
|
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
spreewald (
|
4
|
+
spreewald (2.0.0)
|
5
5
|
cucumber
|
6
6
|
cucumber_priority (>= 0.3.0)
|
7
|
+
rspec
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -153,6 +154,10 @@ GEM
|
|
153
154
|
thor (>= 0.18.1, < 2.0)
|
154
155
|
rake (12.3.2)
|
155
156
|
regexp_parser (1.3.0)
|
157
|
+
rspec (3.8.0)
|
158
|
+
rspec-core (~> 3.8.0)
|
159
|
+
rspec-expectations (~> 3.8.0)
|
160
|
+
rspec-mocks (~> 3.8.0)
|
156
161
|
rspec-core (3.8.0)
|
157
162
|
rspec-support (~> 3.8.0)
|
158
163
|
rspec-expectations (3.8.2)
|
@@ -13,7 +13,7 @@ Feature: Test Spreewald's email steps
|
|
13
13
|
Scenario: /^I should see "([^\"]*)" in the e?mail$/
|
14
14
|
When I go to "/emails/send_email"
|
15
15
|
Then the following step should succeed:
|
16
|
-
| I should see "
|
16
|
+
| I should see "Body" in the email |
|
17
17
|
But the following step should fail:
|
18
18
|
| I should see "XYZ" in the email |
|
19
19
|
|
@@ -23,7 +23,7 @@ Feature: Test Spreewald's email steps
|
|
23
23
|
|
24
24
|
# Test without body
|
25
25
|
Then the following multiline step should succeed:
|
26
|
-
|
26
|
+
"""
|
27
27
|
Then an email should have been sent with:
|
28
28
|
'''
|
29
29
|
From: from@example.com
|
@@ -43,7 +43,10 @@ Feature: Test Spreewald's email steps
|
|
43
43
|
To: to@example.com
|
44
44
|
Subject: SUBJECT
|
45
45
|
|
46
|
-
|
46
|
+
Body
|
47
|
+
with
|
48
|
+
line
|
49
|
+
breaks
|
47
50
|
'''
|
48
51
|
"""
|
49
52
|
|
@@ -57,7 +60,10 @@ Feature: Test Spreewald's email steps
|
|
57
60
|
To: to@example.com
|
58
61
|
Subject: SUBJECT
|
59
62
|
|
60
|
-
|
63
|
+
Body
|
64
|
+
with
|
65
|
+
line
|
66
|
+
breaks
|
61
67
|
'''
|
62
68
|
"""
|
63
69
|
|
@@ -71,12 +77,15 @@ Feature: Test Spreewald's email steps
|
|
71
77
|
To: to@example.com
|
72
78
|
Subject: SUBJECT
|
73
79
|
|
74
|
-
|
80
|
+
Body
|
81
|
+
with
|
82
|
+
line
|
83
|
+
breaks
|
75
84
|
'''
|
76
85
|
"""
|
77
86
|
# Test with incorrect To header
|
78
87
|
Then the following multiline step should fail:
|
79
|
-
|
88
|
+
"""
|
80
89
|
Then an email should have been sent with:
|
81
90
|
'''
|
82
91
|
From: from@example.com
|
@@ -84,13 +93,16 @@ Feature: Test Spreewald's email steps
|
|
84
93
|
To: other-to@example.com
|
85
94
|
Subject: SUBJECT
|
86
95
|
|
87
|
-
|
96
|
+
Body
|
97
|
+
with
|
98
|
+
line
|
99
|
+
breaks
|
88
100
|
'''
|
89
101
|
"""
|
90
102
|
|
91
103
|
# Test with incorrect Subject header
|
92
104
|
Then the following multiline step should fail:
|
93
|
-
|
105
|
+
"""
|
94
106
|
Then an email should have been sent with:
|
95
107
|
'''
|
96
108
|
From: from@example.com
|
@@ -98,7 +110,10 @@ Feature: Test Spreewald's email steps
|
|
98
110
|
To: to@example.com
|
99
111
|
Subject: OTHER-SUBJECT
|
100
112
|
|
101
|
-
|
113
|
+
Body
|
114
|
+
with
|
115
|
+
line
|
116
|
+
breaks
|
102
117
|
'''
|
103
118
|
"""
|
104
119
|
|
@@ -112,7 +127,10 @@ Feature: Test Spreewald's email steps
|
|
112
127
|
To: to@example.com
|
113
128
|
Subject: SUBJECT
|
114
129
|
|
115
|
-
|
130
|
+
Other body
|
131
|
+
with
|
132
|
+
line
|
133
|
+
breaks
|
116
134
|
'''
|
117
135
|
"""
|
118
136
|
|
@@ -126,8 +144,81 @@ Feature: Test Spreewald's email steps
|
|
126
144
|
To: to@example.com
|
127
145
|
Subject: SUBJECT
|
128
146
|
|
129
|
-
|
147
|
+
Body
|
148
|
+
with
|
149
|
+
line
|
150
|
+
breaks
|
130
151
|
|
131
152
|
MORE-BODY
|
132
153
|
'''
|
133
154
|
"""
|
155
|
+
|
156
|
+
Scenario: /^(an|no) e?mail should have been sent((?: |and|with|from "[^"]+"|bcc "[^"]+"|cc "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/
|
157
|
+
When I go to "/emails/send_email"
|
158
|
+
|
159
|
+
# Test with correct conditions
|
160
|
+
Then the following multiline step should succeed:
|
161
|
+
"""
|
162
|
+
Then an email should have been sent from "from@example.com" to "to@example.com" cc "cc@example.com" bcc "bcc@example.com" and the subject "SUBJECT" and the attachments "attached_file.pdf"
|
163
|
+
"""
|
164
|
+
|
165
|
+
# Test with wrong conditions
|
166
|
+
Then the following multiline step should fail:
|
167
|
+
"""
|
168
|
+
Then an email should have been sent from "from@example.com" to "to@example.com" cc "cc@example.com" bcc "wrong_bcc@example.com" and the subject "SUBJECT" and the attachments "attached_file.pdf"
|
169
|
+
"""
|
170
|
+
|
171
|
+
Scenario: /^that e?mail should have the following lines in the body:$/
|
172
|
+
When I go to "/emails/send_email"
|
173
|
+
Then an email should have been sent with:
|
174
|
+
"""
|
175
|
+
From: from@example.com
|
176
|
+
"""
|
177
|
+
|
178
|
+
# Test with correct body lines
|
179
|
+
Then the following multiline step should succeed:
|
180
|
+
"""
|
181
|
+
Then that email should have the following lines in the body:
|
182
|
+
'''
|
183
|
+
with
|
184
|
+
line
|
185
|
+
'''
|
186
|
+
"""
|
187
|
+
|
188
|
+
# Test with wrong body lines
|
189
|
+
Then the following multiline step should fail:
|
190
|
+
"""
|
191
|
+
Then that email should have the following lines in the body:
|
192
|
+
'''
|
193
|
+
wrong
|
194
|
+
line
|
195
|
+
'''
|
196
|
+
"""
|
197
|
+
|
198
|
+
|
199
|
+
Scenario: /^that e?mail should have the following body:$/
|
200
|
+
When I go to "/emails/send_email"
|
201
|
+
Then an email should have been sent with:
|
202
|
+
"""
|
203
|
+
From: from@example.com
|
204
|
+
"""
|
205
|
+
|
206
|
+
# Test with correct body lines
|
207
|
+
Then the following multiline step should succeed:
|
208
|
+
"""
|
209
|
+
Then that email should have the following body:
|
210
|
+
'''
|
211
|
+
with
|
212
|
+
line
|
213
|
+
'''
|
214
|
+
"""
|
215
|
+
|
216
|
+
# Test with wrong body lines
|
217
|
+
Then the following multiline step should fail:
|
218
|
+
"""
|
219
|
+
Then that email should have the following body:
|
220
|
+
'''
|
221
|
+
wrong
|
222
|
+
line
|
223
|
+
'''
|
224
|
+
"""
|
@@ -3,6 +3,7 @@ Feature: Web steps
|
|
3
3
|
Scenario: /^the "([^"]*)" field should (not )?contain "([^"]*)"$/
|
4
4
|
When I go to "/forms/form1"
|
5
5
|
Then the "Text control" field should contain "Text control value"
|
6
|
+
Then the "Text control" field should not contain "false text"
|
6
7
|
Then the "Select control" field should contain "Label 2"
|
7
8
|
Then the "Select control without selection" field should contain "Label 1"
|
8
9
|
Then the "Textarea control" field should contain "Textarea control value"
|
@@ -20,11 +21,29 @@ Feature: Web steps
|
|
20
21
|
Textarea control line 1
|
21
22
|
Textarea control line 2
|
22
23
|
"""
|
24
|
+
Then the "Textarea control" field should not contain:
|
25
|
+
"""
|
26
|
+
Textarea control wrong line 1
|
27
|
+
Textarea control wrong line 2
|
28
|
+
"""
|
23
29
|
Then the "Empty textarea control" field should contain:
|
24
30
|
"""
|
25
31
|
"""
|
26
32
|
|
27
33
|
|
34
|
+
Scenario: /^the "([^\"]*)" field should( not)? have an error$/
|
35
|
+
When I go to "/forms/invalid_form"
|
36
|
+
Then the "Text control" field should have an error
|
37
|
+
Then the "Textarea control" field should have an error
|
38
|
+
Then the "Textarea control" field should have an error
|
39
|
+
Then the "Empty textarea control" field should not have an error
|
40
|
+
|
41
|
+
|
42
|
+
Scenario: /^the "([^"]*)" field should have no error$/
|
43
|
+
When I go to "/forms/invalid_form"
|
44
|
+
Then the "Empty textarea control" field should have no error
|
45
|
+
|
46
|
+
|
28
47
|
Scenario: /^I should see a form with the following values:$/
|
29
48
|
When I go to "/forms/form1"
|
30
49
|
Then I should see a form with the following values:
|
@@ -47,7 +66,18 @@ Feature: Web steps
|
|
47
66
|
Then nothing should be selected for "Select control with blank option"
|
48
67
|
Then nothing should be selected for "Select control with blank selection"
|
49
68
|
|
50
|
-
|
69
|
+
Scenario: /^the radio button "([^"]*)" should( not)? be (?:checked|selected)$/
|
70
|
+
When I go to "/forms/form1"
|
71
|
+
Then the radio button "Radio 1" should not be selected
|
72
|
+
Then the radio button "Radio 2" should not be selected
|
73
|
+
When I choose "Radio 1"
|
74
|
+
Then the radio button "Radio 1" should be selected
|
75
|
+
Then the radio button "Radio 2" should not be selected
|
76
|
+
When I choose "Radio 2"
|
77
|
+
Then the radio button "Radio 1" should not be selected
|
78
|
+
Then the radio button "Radio 2" should be selected
|
79
|
+
|
80
|
+
|
51
81
|
Scenario: /^I go back$/
|
52
82
|
Given I go to "/static_pages/link_to_home"
|
53
83
|
And I follow "Home"
|
@@ -103,7 +133,7 @@ Feature: Web steps
|
|
103
133
|
|
104
134
|
Scenario: /^Then (the tag )?"..." should( not)? be visible$/
|
105
135
|
When I go to "/static_pages/visibility"
|
106
|
-
Then "hidden ümläüt" should
|
136
|
+
Then "hidden ümläüt" should be hidden
|
107
137
|
And "visible ümläüt" should be visible
|
108
138
|
And a hidden string with quotes should not be visible
|
109
139
|
And a visible string with quotes should be visible
|
@@ -113,7 +143,7 @@ Feature: Web steps
|
|
113
143
|
@javascript
|
114
144
|
Scenario: /^Then (the tag )?"..." should( not)? be visible$/ with javascript
|
115
145
|
When I go to "/static_pages/visibility"
|
116
|
-
Then "hidden ümläüt" should
|
146
|
+
Then "hidden ümläüt" should be hidden
|
117
147
|
And "visible ümläüt" should be visible
|
118
148
|
And a hidden string with quotes should not be visible
|
119
149
|
And a visible string with quotes should be visible
|
@@ -2,29 +2,34 @@ class Mailer < ActionMailer::Base
|
|
2
2
|
|
3
3
|
REPLY_TO = "reply-to@example.com"
|
4
4
|
TO = "to@example.com"
|
5
|
+
CC = "cc@example.com"
|
6
|
+
BCC = "bcc@example.com"
|
5
7
|
FROM = "from@example.com"
|
6
8
|
SUBJECT = "SUBJECT"
|
7
|
-
BODY = "BODY"
|
8
9
|
|
9
10
|
if Rails.version >= "3"
|
10
11
|
|
11
12
|
def email
|
13
|
+
attachments['attached_file.pdf'] = File.open("../../tmp/attachment.pdf", "w") {}
|
12
14
|
mail(
|
13
15
|
:from => FROM,
|
14
16
|
:reply_to => REPLY_TO,
|
15
17
|
:to => TO,
|
18
|
+
:cc => CC,
|
19
|
+
:bcc => BCC,
|
16
20
|
:subject => SUBJECT
|
17
|
-
)
|
18
|
-
format.text { render :text => BODY }
|
19
|
-
end
|
21
|
+
)
|
20
22
|
end
|
21
23
|
|
22
24
|
else
|
23
25
|
|
24
26
|
def email
|
27
|
+
attachments['attached_file.pdf'] = File.open("../../tmp/attachment.pdf", "w") {}
|
25
28
|
recipients TO
|
26
29
|
reply_to REPLY_TO
|
27
30
|
from FROM
|
31
|
+
cc CC
|
32
|
+
bcc BCC
|
28
33
|
subject SUBJECT
|
29
34
|
body BODY
|
30
35
|
end
|