spreewald 3.0.0 → 4.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.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +42 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +35 -0
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +2 -2
  7. data/Gemfile.ruby245 +3 -0
  8. data/Gemfile.ruby245.lock +11 -2
  9. data/Gemfile.ruby266 +3 -0
  10. data/Gemfile.ruby266.lock +12 -2
  11. data/{Gemfile.ruby218 → Gemfile.ruby300} +6 -1
  12. data/Gemfile.ruby300.lock +108 -0
  13. data/README.md +41 -3
  14. data/Rakefile +34 -19
  15. data/features/binary.feature +2 -2
  16. data/features/support/step_definitions/custom_steps.rb +10 -0
  17. data/lib/spreewald.rb +1 -0
  18. data/lib/spreewald/browser_tab_steps.rb +1 -1
  19. data/lib/spreewald/email_steps.rb +3 -1
  20. data/lib/spreewald/frame_steps.rb +77 -0
  21. data/lib/spreewald_support/mail_finder.rb +12 -10
  22. data/lib/spreewald_support/mail_to_plaintext_converter.rb +42 -0
  23. data/lib/spreewald_support/unsupported_email_header.rb +22 -0
  24. data/lib/spreewald_support/version.rb +1 -1
  25. data/spec/spreewald_support/mail_to_plaintext_converter_spec.rb +60 -0
  26. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Gemfile +1 -1
  27. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Gemfile.lock +15 -17
  28. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/README.rdoc +0 -0
  29. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Rakefile +0 -0
  30. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/app +0 -0
  31. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/bundle +0 -0
  32. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/rails +0 -0
  33. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/rake +0 -0
  34. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/setup +0 -0
  35. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config.ru +0 -0
  36. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/application.rb +0 -0
  37. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/boot.rb +0 -0
  38. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/cucumber.yml +0 -0
  39. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/database.yml +0 -0
  40. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environment.rb +0 -0
  41. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environments/development.rb +0 -0
  42. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environments/test.rb +0 -0
  43. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/backtrace_silencers.rb +0 -0
  44. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/cookies_serializer.rb +0 -0
  45. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/filter_parameter_logging.rb +0 -0
  46. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/inflections.rb +0 -0
  47. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/mime_types.rb +0 -0
  48. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/session_store.rb +0 -0
  49. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/silence_deprecation_warnings.rb +0 -0
  50. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/to_time_preserves_timezone.rb +0 -0
  51. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/wrap_parameters.rb +0 -0
  52. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/locales/en.yml +0 -0
  53. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/config/routes.rb +0 -0
  54. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/secrets.yml +0 -0
  55. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/db +0 -0
  56. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/browser_tab_steps.feature +0 -0
  57. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/development_steps.feature +0 -0
  58. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/email_steps.feature +0 -0
  59. data/tests/rails-4_capybara-2/features/iframe_steps.feature +1 -0
  60. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/overriding.feature +0 -0
  61. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/session_steps.feature +0 -0
  62. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/overriding_steps.rb +0 -0
  63. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/test_steps.rb +0 -0
  64. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/support/env.rb +0 -0
  65. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/features/support/paths.rb +0 -0
  66. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/features/support/selectors.rb +0 -0
  67. data/tests/rails-4_capybara-2/features/support/selenium.rb +1 -0
  68. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/table_steps.feature +0 -0
  69. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/time_steps.feature +0 -0
  70. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/web_steps.feature +0 -0
  71. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/lib/tasks/cucumber.rake +0 -0
  72. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/log/.keep +0 -0
  73. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/404.html +0 -0
  74. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/422.html +0 -0
  75. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/500.html +0 -0
  76. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/favicon.ico +0 -0
  77. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/fixture_files +0 -0
  78. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/script/cucumber +0 -0
  79. data/tests/rails-6_capybara-3/.ruby-version +1 -1
  80. data/tests/rails-6_capybara-3/Gemfile +4 -2
  81. data/tests/rails-6_capybara-3/Gemfile.lock +177 -143
  82. data/tests/rails-6_capybara-3/app/mailers/spreewald_mailer.rb +28 -0
  83. data/tests/rails-6_capybara-3/config.ru +1 -0
  84. data/tests/rails-6_capybara-3/config/cucumber.yml +1 -1
  85. data/tests/rails-6_capybara-3/config/environments/development.rb +21 -3
  86. data/tests/rails-6_capybara-3/config/environments/test.rb +12 -1
  87. data/tests/rails-6_capybara-3/config/initializers/backtrace_silencers.rb +4 -3
  88. data/tests/rails-6_capybara-3/config/initializers/filter_parameter_logging.rb +3 -1
  89. data/tests/rails-6_capybara-3/config/initializers/new_framework_defaults_6_1.rb +67 -0
  90. data/tests/rails-6_capybara-3/config/initializers/permissions_policy.rb +11 -0
  91. data/tests/rails-6_capybara-3/features/iframe_steps.feature +1 -0
  92. data/tests/rails-6_capybara-3/features/support/selenium.rb +1 -0
  93. data/tests/shared/app/controllers/emails_controller.rb +35 -0
  94. data/tests/shared/app/controllers/iframes_controller.rb +11 -0
  95. data/tests/shared/app/controllers/static_pages_controller.rb +12 -8
  96. data/tests/shared/app/models/mailer.rb +52 -0
  97. data/tests/shared/app/views/iframes/iframe_1_content.haml +12 -0
  98. data/tests/shared/app/views/iframes/iframe_2_content.haml +12 -0
  99. data/tests/shared/app/views/mailer/html_email_for_failed_test_without_header.haml +5 -0
  100. data/tests/shared/app/views/mailer/html_email_for_successful_test_without_header.haml +7 -0
  101. data/tests/shared/app/views/mailer/html_email_with_linebreaks.html +6 -0
  102. data/tests/shared/app/views/mailer/html_email_with_specific_line.haml +11 -0
  103. data/tests/shared/app/views/mailer/text_email_for_failed_test_without_header.text.erb +1 -0
  104. data/tests/shared/app/views/mailer/text_email_for_successful_test_without_header.text.erb +3 -0
  105. data/tests/shared/app/views/mailer/text_email_with_specific_line.text.erb +5 -0
  106. data/tests/shared/app/views/static_pages/iframe.haml +3 -0
  107. data/tests/shared/config/routes.rb +11 -0
  108. data/tests/shared/features/shared/email_steps.feature +240 -0
  109. data/tests/shared/features/shared/iframe_steps.feature +38 -0
  110. data/tests/shared/features/shared/step_definitions/test_steps.rb +5 -6
  111. data/tests/shared/features/support/selenium.rb +10 -0
  112. metadata +149 -184
  113. data/.travis.yml +0 -29
  114. data/Gemfile.ruby218.lock +0 -58
  115. data/tests/rails-3_capybara-1/.ruby-version +0 -1
  116. data/tests/rails-3_capybara-1/Gemfile +0 -20
  117. data/tests/rails-3_capybara-1/Gemfile.lock +0 -182
  118. data/tests/rails-3_capybara-1/Rakefile +0 -18
  119. data/tests/rails-3_capybara-1/app +0 -1
  120. data/tests/rails-3_capybara-1/config.ru +0 -4
  121. data/tests/rails-3_capybara-1/config/application.rb +0 -29
  122. data/tests/rails-3_capybara-1/config/boot.rb +0 -15
  123. data/tests/rails-3_capybara-1/config/cucumber.yml +0 -1
  124. data/tests/rails-3_capybara-1/config/database.yml +0 -1
  125. data/tests/rails-3_capybara-1/config/environment.rb +0 -7
  126. data/tests/rails-3_capybara-1/config/initializers/backtrace_silencers.rb +0 -9
  127. data/tests/rails-3_capybara-1/config/initializers/inflections.rb +0 -12
  128. data/tests/rails-3_capybara-1/config/initializers/mime_types.rb +0 -7
  129. data/tests/rails-3_capybara-1/config/initializers/secret_token.rb +0 -9
  130. data/tests/rails-3_capybara-1/config/initializers/session_store.rb +0 -5
  131. data/tests/rails-3_capybara-1/db +0 -1
  132. data/tests/rails-3_capybara-1/features/shared +0 -1
  133. data/tests/rails-3_capybara-1/features/support/env.rb +0 -65
  134. data/tests/rails-3_capybara-1/features/support/selenium.rb +0 -3
  135. data/tests/rails-3_capybara-1/public +0 -1
  136. data/tests/rails-3_capybara-1/script/rails +0 -6
  137. data/tests/rails-3_capybara-2/.ruby-version +0 -1
  138. data/tests/rails-3_capybara-2/Gemfile +0 -21
  139. data/tests/rails-3_capybara-2/Gemfile.lock +0 -191
  140. data/tests/rails-3_capybara-2/Rakefile +0 -1
  141. data/tests/rails-3_capybara-2/app +0 -1
  142. data/tests/rails-3_capybara-2/config +0 -1
  143. data/tests/rails-3_capybara-2/config.ru +0 -1
  144. data/tests/rails-3_capybara-2/db +0 -1
  145. data/tests/rails-3_capybara-2/features +0 -1
  146. data/tests/rails-3_capybara-2/public +0 -1
  147. data/tests/rails-3_capybara-2/script +0 -1
  148. data/tests/rails-4_capybara-3/config/routes.rb +0 -1
  149. data/tests/rails-4_capybara-3/features/support/paths.rb +0 -1
  150. data/tests/rails-4_capybara-3/features/support/selectors.rb +0 -1
  151. data/tests/rails-4_capybara-3/features/support/selenium.rb +0 -3
  152. data/tests/rails-4_capybara-3/script/cucumber +0 -10
  153. data/tests/rails-6_capybara-3/features/support/selenium.rb +0 -3
@@ -240,7 +240,7 @@ Feature: The `spreewald` binary
240
240
 
241
241
  Scenario: Print version
242
242
  When I run `spreewald --version`
243
- Then the output should contain "Spreewald 3."
243
+ Then the output should contain /Spreewald \d./
244
244
 
245
245
  When I run `spreewald -v`
246
- Then the output should contain "Spreewald 3."
246
+ Then the output should contain /Spreewald \d./
@@ -0,0 +1,10 @@
1
+ Then /^the output should( not)? contain \/(.*)\/$/ do |negated, regexp|
2
+ output = all_commands.map { |c| c.output }.join("\n")
3
+ regexp = Regexp.new(regexp)
4
+
5
+ if negated
6
+ expect(output).not_to match(regexp)
7
+ else
8
+ expect(output).to match(regexp)
9
+ end
10
+ end
data/lib/spreewald.rb CHANGED
@@ -3,3 +3,4 @@
3
3
  require 'cucumber_priority'
4
4
  require "spreewald_support/version"
5
5
  require "spreewald_support/github"
6
+ require "spreewald_support/unsupported_email_header"
@@ -19,7 +19,7 @@ When /^I open (.+?) in a new browser tab$/ do |page_name|
19
19
  previous_handles_count = browser.window_handles.size
20
20
  relative_target_path = path_to(page_name)
21
21
 
22
- page.execute_script "window.open('#{relative_target_path}', '_blank')"
22
+ page.execute_script "window.open('#{relative_target_path}', '_blank', 'noopener')"
23
23
  step "there should be #{previous_handles_count + 1} browser tabs"
24
24
  step "I switch to the new browser tab"
25
25
  end.overridable
@@ -30,7 +30,9 @@ end.overridable
30
30
  #
31
31
  # """
32
32
  #
33
- # You may skip lines in the header, of course.
33
+ # You may skip lines in the header.
34
+ # Please note: In older versions of Spreewald, unmentioned body lines were skipped.
35
+ # Now you have to use the asterisk explicitly to omit lines in the body.
34
36
  Then /^(an?|no)( HTML| plain-text|) e?mail should have been sent with:$/ do |mode, type, raw_data|
35
37
  patiently do
36
38
  results = MailFinder.find(raw_data, type.strip)
@@ -0,0 +1,77 @@
1
+ # You can append `inside the [name or number] iframe` to any other step.
2
+ # Then the step will operate inside the given iframe.
3
+ # Examples:
4
+ #
5
+ # Then I should see "Kiwi" inside the 1st iframe
6
+ # Then I should see "Cherry" inside the fruits iframe
7
+ # When I press "Save" inside the 2nd iframe
8
+ #
9
+ When /^(.*?) inside the (.*?) iframe$/ do |nested_step, frame_identifier|
10
+ patiently do
11
+ frame = find_frame(frame_identifier)
12
+ page.within_frame(frame) do
13
+ step nested_step
14
+ end
15
+ end
16
+ end.overridable
17
+
18
+ # nodoc
19
+ When /^(.*?) inside the (.*?) iframe:$/ do |nested_step, frame_identifier, table_or_string|
20
+ patiently do
21
+ frame = find_frame(frame_identifier)
22
+ page.within_frame(frame) do
23
+ step("#{nested_step}:", table_or_string)
24
+ end
25
+ end
26
+ end.overridable
27
+
28
+ if Gem::Version.new(Capybara::VERSION) >= Gem::Version.new('3')
29
+
30
+ # This step will switch to the iframe identified by its name or number.
31
+ # All further steps will operate inside the iframe.
32
+ # To switch to operating on the main page again, use the step
33
+ # "I switch back to the whole page".
34
+ # Examples:
35
+ #
36
+ # When I switch to the 1st iframe
37
+ # When I switch to the fruits iframe
38
+ #
39
+ # Please note: This step is only available for Capybara >= 3.
40
+ When /^I switch to the (.*?) iframe$/ do |frame_identifier|
41
+ frame = find_frame(frame_identifier)
42
+ page.driver.switch_to_frame(frame)
43
+ end.overridable
44
+
45
+ # This step can be used to switch back to the whole page if you switched
46
+ # to operating inside an iframe before (step `I switch to the ... iframe`).
47
+ #
48
+ # Please note: This step is only available for Capybara >= 3.
49
+ When /^I switch back to the whole page$/ do
50
+ handle = page.driver.current_window_handle
51
+ page.driver.switch_to_window(handle)
52
+ end
53
+ end
54
+
55
+ module IframeStepsHelper
56
+ def find_frame(frame_identifier)
57
+ frame_id = convert_frame_identifier(frame_identifier)
58
+ case frame_id
59
+ when Integer
60
+ frames = page.find_all('iframe')
61
+ frames[frame_id]
62
+ when String
63
+ page.find("iframe[name='#{frame_id}']")
64
+ end
65
+ end
66
+
67
+ def convert_frame_identifier(frame_identifier)
68
+ number_regex = /\A(?<number>\d+)(st|nd|rd|th|\.)\z/
69
+ matches = frame_identifier.match(number_regex)
70
+ if matches && matches[:number]
71
+ matches[:number].to_i - 1 # selenium starts counting a 0
72
+ else
73
+ frame_identifier
74
+ end
75
+ end
76
+ end
77
+ World(IframeStepsHelper)
@@ -1,20 +1,29 @@
1
1
  # coding: UTF-8
2
+ require "spreewald_support/mail_to_plaintext_converter"
3
+ require "forwardable"
2
4
 
3
5
  class MailFinder
6
+
4
7
  class << self
5
8
 
6
9
  attr_accessor :user_identity
7
10
 
8
11
  def find(raw_data, type = '')
9
- header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
12
+ header, body = raw_data.split(/\n\n/, 2).map(&:strip_heredoc) # 2: maximum number of fields
10
13
  conditions = {}
11
14
  header.split("\n").each do |row|
12
15
  if row.match(/^[A-Za-z\-]+: /i)
13
16
  key, value = row.split(": ", 2)
17
+ raise Spreewald::UnsupportedEmailHeader.new(key, value) unless Spreewald::SUPPORTED_EMAIL_HEADERS.include? key.strip
14
18
  conditions[key.strip.underscore.to_sym] = value.strip
15
19
  end
16
20
  end
17
21
 
22
+ # Interpret all lines as body if there are no header-link lines
23
+ if conditions.blank?
24
+ body = [header, body].join("\n\n")
25
+ end
26
+
18
27
  filename_method = Rails::VERSION::MAJOR < 3 ? 'original_filename' : 'filename'
19
28
  matching_header = ActionMailer::Base.deliveries.select do |mail|
20
29
  [ conditions[:to].nil? || mail.to.include?(resolve_email conditions[:to]),
@@ -58,15 +67,7 @@ class MailFinder
58
67
  end
59
68
 
60
69
  def email_text_body(mail, type = '')
61
- body = if mail.html_part && type != 'plain-text'
62
- dom = Nokogiri::HTML(mail.html_part.body.to_s)
63
- dom.at_css('body').text.gsub(/\n\n/, "\n")
64
- elsif mail.text_part && type != 'HTML'
65
- mail.text_part.body.to_s
66
- else
67
- mail.body.to_s
68
- end
69
- 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.
70
+ Spreewald::MailToPlaintextConverter.new(mail, type).run
70
71
  end
71
72
 
72
73
  def show_mails(mails, only_header = false)
@@ -85,6 +86,7 @@ class MailFinder
85
86
  expected = '\A\n' + Regexp.quote(expected_body.strip) + '\n\Z'
86
87
  expected.gsub! '\n\*\n', '\n[\s\S]*\n'
87
88
  expected.gsub! '\*\n', '.*\n'
89
+ expected.gsub! '\n\*', '\n.*'
88
90
 
89
91
  expected.gsub! '\A\n', '\A'
90
92
  expected.gsub! '\n\Z', '\Z'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Spreewald
2
- VERSION = '3.0.0'
2
+ VERSION = '4.1.1'
3
3
  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
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  group :test do
16
16
  gem 'database_cleaner'
17
- gem 'capybara', "~>3"
17
+ gem 'capybara', '<3'
18
18
  gem 'capybara-screenshot'
19
19
  gem 'cucumber-rails', require: false
20
20
  gem 'cucumber'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (3.0.0)
4
+ spreewald (4.1.1)
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.6.0)
47
- public_suffix (>= 2.0.2, < 4.0)
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 (3.14.0)
52
+ capybara (2.18.0)
53
53
  addressable
54
54
  mini_mime (>= 0.1.3)
55
- nokogiri (~> 1.8)
56
- rack (>= 1.6.0)
57
- rack-test (>= 0.6.3)
58
- regexp_parser (~> 1.2)
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.3.4)
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.1)
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.1)
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 (3.0.3)
138
- rack (1.6.12)
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 (~> 3)
215
+ capybara (< 3)
218
216
  capybara-screenshot
219
217
  cucumber
220
218
  cucumber-rails
@@ -229,4 +227,4 @@ DEPENDENCIES
229
227
  sqlite3
230
228
 
231
229
  BUNDLED WITH
232
- 1.17.3
230
+ 2.2.4