spreewald 3.0.3 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +40 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/Gemfile.ruby245 +3 -0
- data/Gemfile.ruby245.lock +10 -1
- data/Gemfile.ruby266 +3 -0
- data/Gemfile.ruby266.lock +12 -2
- data/README.md +41 -3
- data/Rakefile +34 -19
- data/features/binary.feature +2 -2
- data/features/support/step_definitions/custom_steps.rb +10 -0
- data/lib/spreewald.rb +1 -0
- data/lib/spreewald/email_steps.rb +3 -1
- data/lib/spreewald/frame_steps.rb +77 -0
- data/lib/spreewald_support/mail_finder.rb +6 -10
- data/lib/spreewald_support/mail_to_plaintext_converter.rb +42 -0
- data/lib/spreewald_support/unsupported_email_header.rb +22 -0
- data/lib/spreewald_support/version.rb +1 -1
- data/spec/spreewald_support/mail_to_plaintext_converter_spec.rb +60 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Gemfile +1 -1
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Gemfile.lock +14 -16
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/README.rdoc +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Rakefile +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/app +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/bundle +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/rails +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/rake +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/setup +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config.ru +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/application.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/boot.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/cucumber.yml +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/database.yml +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environment.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environments/development.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environments/test.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/backtrace_silencers.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/cookies_serializer.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/filter_parameter_logging.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/inflections.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/mime_types.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/session_store.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/silence_deprecation_warnings.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/to_time_preserves_timezone.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/wrap_parameters.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/locales/en.yml +0 -0
- data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/config/routes.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/secrets.yml +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/db +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/browser_tab_steps.feature +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/development_steps.feature +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/email_steps.feature +0 -0
- data/tests/rails-4_capybara-2/features/iframe_steps.feature +1 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/overriding.feature +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/session_steps.feature +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/overriding_steps.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/test_steps.rb +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/support/env.rb +0 -0
- data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/features/support/paths.rb +0 -0
- data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/features/support/selectors.rb +0 -0
- data/tests/rails-4_capybara-2/features/support/selenium.rb +1 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/table_steps.feature +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/time_steps.feature +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/web_steps.feature +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/lib/tasks/cucumber.rake +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/log/.keep +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/404.html +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/422.html +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/500.html +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/favicon.ico +0 -0
- data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/fixture_files +0 -0
- data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/script/cucumber +0 -0
- data/tests/rails-6_capybara-3/Gemfile.lock +2 -2
- data/tests/rails-6_capybara-3/features/iframe_steps.feature +1 -0
- data/tests/rails-6_capybara-3/features/support/selenium.rb +1 -0
- data/tests/shared/app/controllers/iframes_controller.rb +11 -0
- data/tests/shared/app/controllers/static_pages_controller.rb +12 -8
- data/tests/shared/app/views/iframes/iframe_1_content.haml +12 -0
- data/tests/shared/app/views/iframes/iframe_2_content.haml +12 -0
- data/tests/shared/app/views/static_pages/iframe.haml +3 -0
- data/tests/shared/config/routes.rb +4 -0
- data/tests/shared/features/shared/email_steps.feature +64 -0
- data/tests/shared/features/shared/iframe_steps.feature +38 -0
- data/tests/shared/features/shared/step_definitions/test_steps.rb +5 -6
- data/tests/shared/features/support/selenium.rb +10 -0
- metadata +128 -183
- data/.travis.yml +0 -29
- data/Gemfile.ruby218 +0 -7
- data/Gemfile.ruby218.lock +0 -58
- data/tests/rails-3_capybara-1/.ruby-version +0 -1
- data/tests/rails-3_capybara-1/Gemfile +0 -20
- data/tests/rails-3_capybara-1/Gemfile.lock +0 -182
- data/tests/rails-3_capybara-1/Rakefile +0 -18
- data/tests/rails-3_capybara-1/app +0 -1
- data/tests/rails-3_capybara-1/config.ru +0 -4
- data/tests/rails-3_capybara-1/config/application.rb +0 -29
- data/tests/rails-3_capybara-1/config/boot.rb +0 -15
- data/tests/rails-3_capybara-1/config/cucumber.yml +0 -1
- data/tests/rails-3_capybara-1/config/database.yml +0 -1
- data/tests/rails-3_capybara-1/config/environment.rb +0 -7
- data/tests/rails-3_capybara-1/config/initializers/backtrace_silencers.rb +0 -9
- data/tests/rails-3_capybara-1/config/initializers/inflections.rb +0 -12
- data/tests/rails-3_capybara-1/config/initializers/mime_types.rb +0 -7
- data/tests/rails-3_capybara-1/config/initializers/secret_token.rb +0 -9
- data/tests/rails-3_capybara-1/config/initializers/session_store.rb +0 -5
- data/tests/rails-3_capybara-1/db +0 -1
- data/tests/rails-3_capybara-1/features/shared +0 -1
- data/tests/rails-3_capybara-1/features/support/env.rb +0 -65
- data/tests/rails-3_capybara-1/features/support/selenium.rb +0 -3
- data/tests/rails-3_capybara-1/public +0 -1
- data/tests/rails-3_capybara-1/script/rails +0 -6
- data/tests/rails-3_capybara-2/.ruby-version +0 -1
- data/tests/rails-3_capybara-2/Gemfile +0 -21
- data/tests/rails-3_capybara-2/Gemfile.lock +0 -191
- data/tests/rails-3_capybara-2/Rakefile +0 -1
- data/tests/rails-3_capybara-2/app +0 -1
- data/tests/rails-3_capybara-2/config +0 -1
- data/tests/rails-3_capybara-2/config.ru +0 -1
- data/tests/rails-3_capybara-2/db +0 -1
- data/tests/rails-3_capybara-2/features +0 -1
- data/tests/rails-3_capybara-2/public +0 -1
- data/tests/rails-3_capybara-2/script +0 -1
- data/tests/rails-4_capybara-3/config/routes.rb +0 -1
- data/tests/rails-4_capybara-3/features/support/paths.rb +0 -1
- data/tests/rails-4_capybara-3/features/support/selectors.rb +0 -1
- data/tests/rails-4_capybara-3/features/support/selenium.rb +0 -3
- data/tests/rails-4_capybara-3/script/cucumber +0 -10
- data/tests/rails-6_capybara-3/features/support/selenium.rb +0 -3
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Spreewald
|
4
|
+
class MailToPlaintextConverter
|
5
|
+
def initialize(mail, type = '')
|
6
|
+
@mail = mail
|
7
|
+
@type = type
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
body = ''
|
12
|
+
if mail.multipart?
|
13
|
+
body = if mail.html_part && type != 'plain-text'
|
14
|
+
text_from_html(mail.html_part.body.to_s)
|
15
|
+
elsif mail.text_part && type != 'HTML'
|
16
|
+
mail.text_part.body.to_s
|
17
|
+
else
|
18
|
+
mail.body.to_s
|
19
|
+
end
|
20
|
+
else
|
21
|
+
if body_text_html?
|
22
|
+
body = text_from_html(mail.body.to_s)
|
23
|
+
else
|
24
|
+
body = mail.body.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
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.
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :mail, :type
|
33
|
+
|
34
|
+
def body_text_html?
|
35
|
+
mail.body.to_s.include? "<html>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def text_from_html(html)
|
39
|
+
Nokogiri::HTML(html).at_css('body').text.gsub(/[\r\n]+/, "\n")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Spreewald
|
2
|
+
SUPPORTED_EMAIL_HEADERS = ["To", "CC", "BCC", "From", "Reply-To", "Subject", "Attachments"]
|
3
|
+
|
4
|
+
class UnsupportedEmailHeader < StandardError
|
5
|
+
attr_reader :header, :value
|
6
|
+
|
7
|
+
def initialize(header, value)
|
8
|
+
@header, @value = header, value
|
9
|
+
error_message = <<-MESSAGE.strip_heredoc
|
10
|
+
It looks like you're trying to match against an unsupported header "#{header}".
|
11
|
+
The following headers are supported: #{supported_headers_list}
|
12
|
+
MESSAGE
|
13
|
+
super(error_message)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def supported_headers_list
|
19
|
+
SUPPORTED_EMAIL_HEADERS.join(", ")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "spreewald_support/mail_to_plaintext_converter"
|
2
|
+
require "mail"
|
3
|
+
|
4
|
+
describe Spreewald::MailToPlaintextConverter do
|
5
|
+
describe '#run' do
|
6
|
+
context 'with multipart email' do
|
7
|
+
let(:multipart_email) do
|
8
|
+
Mail.new do
|
9
|
+
text_part do
|
10
|
+
body "email text part"
|
11
|
+
end
|
12
|
+
|
13
|
+
html_part do
|
14
|
+
body "<html><body><p>html email text</p></body></html>"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'uses the html part as source as default' do
|
20
|
+
output = Spreewald::MailToPlaintextConverter.new(multipart_email).run
|
21
|
+
expect(output).to eq 'html email text'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'uses the text part as source if specified as type' do
|
25
|
+
output = Spreewald::MailToPlaintextConverter.new(multipart_email, 'plain-text').run
|
26
|
+
expect(output).to eq 'email text part'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'uses the html part as source if specified as type' do
|
30
|
+
output = Spreewald::MailToPlaintextConverter.new(multipart_email, 'HTML').run
|
31
|
+
expect(output).to eq 'html email text'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'without multipart email' do
|
36
|
+
it 'recognizes the plaintext' do
|
37
|
+
plaintext_email = Mail.new(body: 'Hello RSpec')
|
38
|
+
output = Spreewald::MailToPlaintextConverter.new(plaintext_email).run
|
39
|
+
expect(output).to eq 'Hello RSpec'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'recognizes html content' do
|
43
|
+
plaintext_email = Mail.new(body: <<-HTML)
|
44
|
+
<html><body><p>this is html!</p></body></html>
|
45
|
+
HTML
|
46
|
+
output = Spreewald::MailToPlaintextConverter.new(plaintext_email).run
|
47
|
+
expect(output).to eq 'this is html!'
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'recognizes multiple paragraph content' do
|
51
|
+
plaintext_email = Mail.new(body: <<~HTML)
|
52
|
+
<html><body><p>this is line1</p>
|
53
|
+
<p>this is line2</p></body></html>
|
54
|
+
HTML
|
55
|
+
output = Spreewald::MailToPlaintextConverter.new(plaintext_email).run
|
56
|
+
expect(output).to eq "this is line1\nthis is line2"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
spreewald (
|
4
|
+
spreewald (4.1.0)
|
5
5
|
cucumber
|
6
6
|
cucumber_priority (>= 0.3.0)
|
7
7
|
rspec (>= 2.13.0)
|
@@ -43,20 +43,19 @@ GEM
|
|
43
43
|
minitest (~> 5.1)
|
44
44
|
thread_safe (~> 0.3, >= 0.3.4)
|
45
45
|
tzinfo (~> 1.1)
|
46
|
-
addressable (2.
|
47
|
-
public_suffix (>= 2.0.2, <
|
46
|
+
addressable (2.7.0)
|
47
|
+
public_suffix (>= 2.0.2, < 5.0)
|
48
48
|
arel (6.0.4)
|
49
49
|
backports (3.12.0)
|
50
50
|
builder (3.2.3)
|
51
51
|
byebug (10.0.2)
|
52
|
-
capybara (
|
52
|
+
capybara (2.18.0)
|
53
53
|
addressable
|
54
54
|
mini_mime (>= 0.1.3)
|
55
|
-
nokogiri (
|
56
|
-
rack (>= 1.
|
57
|
-
rack-test (>= 0.
|
58
|
-
|
59
|
-
xpath (~> 3.2)
|
55
|
+
nokogiri (>= 1.3.3)
|
56
|
+
rack (>= 1.0.0)
|
57
|
+
rack-test (>= 0.5.4)
|
58
|
+
xpath (>= 2.0, < 4.0)
|
60
59
|
capybara-screenshot (1.0.22)
|
61
60
|
capybara (>= 1.0, < 4)
|
62
61
|
launchy
|
@@ -93,7 +92,7 @@ GEM
|
|
93
92
|
diff-lcs (1.3)
|
94
93
|
erubis (2.7.0)
|
95
94
|
ffi (1.10.0)
|
96
|
-
gemika (0.
|
95
|
+
gemika (0.5.0)
|
97
96
|
gherkin (5.1.0)
|
98
97
|
globalid (0.4.2)
|
99
98
|
activesupport (>= 4.2.0)
|
@@ -124,18 +123,18 @@ GEM
|
|
124
123
|
mime-types (3.2.2)
|
125
124
|
mime-types-data (~> 3.2015)
|
126
125
|
mime-types-data (3.2018.0812)
|
127
|
-
mini_mime (1.0.
|
126
|
+
mini_mime (1.0.2)
|
128
127
|
mini_portile2 (2.4.0)
|
129
128
|
minitest (5.11.3)
|
130
129
|
multi_json (1.13.1)
|
131
130
|
multi_test (0.1.2)
|
132
|
-
nokogiri (1.10.
|
131
|
+
nokogiri (1.10.10)
|
133
132
|
mini_portile2 (~> 2.4.0)
|
134
133
|
pry (0.12.2)
|
135
134
|
coderay (~> 1.1.0)
|
136
135
|
method_source (~> 0.9.0)
|
137
|
-
public_suffix (
|
138
|
-
rack (1.6.
|
136
|
+
public_suffix (4.0.6)
|
137
|
+
rack (1.6.13)
|
139
138
|
rack-test (0.6.3)
|
140
139
|
rack (>= 1.0)
|
141
140
|
rails (4.2.11)
|
@@ -163,7 +162,6 @@ GEM
|
|
163
162
|
rake (>= 0.8.7)
|
164
163
|
thor (>= 0.18.1, < 2.0)
|
165
164
|
rake (12.3.2)
|
166
|
-
regexp_parser (1.3.0)
|
167
165
|
rspec (3.8.0)
|
168
166
|
rspec-core (~> 3.8.0)
|
169
167
|
rspec-expectations (~> 3.8.0)
|
@@ -214,7 +212,7 @@ PLATFORMS
|
|
214
212
|
|
215
213
|
DEPENDENCIES
|
216
214
|
byebug
|
217
|
-
capybara (
|
215
|
+
capybara (< 3)
|
218
216
|
capybara-screenshot
|
219
217
|
cucumber
|
220
218
|
cucumber-rails
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/backtrace_silencers.rb
RENAMED
File without changes
|
data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/cookies_serializer.rb
RENAMED
File without changes
|
data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/filter_parameter_logging.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
../../shared/features/shared/iframe_steps.feature
|
File without changes
|
File without changes
|
data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/overriding_steps.rb
RENAMED
File without changes
|
data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/test_steps.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
../../../shared/features/support/selenium.rb
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
spreewald (
|
4
|
+
spreewald (4.1.0)
|
5
5
|
cucumber
|
6
6
|
cucumber_priority (>= 0.3.0)
|
7
7
|
rspec (>= 2.13.0)
|
@@ -112,7 +112,7 @@ GEM
|
|
112
112
|
diff-lcs (1.3)
|
113
113
|
erubi (1.9.0)
|
114
114
|
erubis (2.7.0)
|
115
|
-
gemika (0.
|
115
|
+
gemika (0.5.0)
|
116
116
|
gherkin (5.1.0)
|
117
117
|
globalid (0.4.2)
|
118
118
|
activesupport (>= 4.2.0)
|
@@ -0,0 +1 @@
|
|
1
|
+
../../shared/features/shared/iframe_steps.feature
|
@@ -0,0 +1 @@
|
|
1
|
+
../../../shared/features/support/selenium.rb
|
@@ -6,6 +6,14 @@ class StaticPagesController < ApplicationController
|
|
6
6
|
def home
|
7
7
|
end
|
8
8
|
|
9
|
+
def iframe
|
10
|
+
render 'static_pages/iframe', layout: false
|
11
|
+
end
|
12
|
+
|
13
|
+
def link_target
|
14
|
+
render_nothing
|
15
|
+
end
|
16
|
+
|
9
17
|
def link_to_home
|
10
18
|
end
|
11
19
|
|
@@ -18,6 +26,10 @@ class StaticPagesController < ApplicationController
|
|
18
26
|
def overriden
|
19
27
|
end
|
20
28
|
|
29
|
+
def second_link_target
|
30
|
+
render_nothing
|
31
|
+
end
|
32
|
+
|
21
33
|
def see_element
|
22
34
|
end
|
23
35
|
|
@@ -36,12 +48,4 @@ class StaticPagesController < ApplicationController
|
|
36
48
|
def within
|
37
49
|
end
|
38
50
|
|
39
|
-
def link_target
|
40
|
-
render_nothing
|
41
|
-
end
|
42
|
-
|
43
|
-
def second_link_target
|
44
|
-
render_nothing
|
45
|
-
end
|
46
|
-
|
47
51
|
end
|