spreewald 3.0.3 → 4.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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +40 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +2 -2
  6. data/Gemfile.ruby245 +3 -0
  7. data/Gemfile.ruby245.lock +10 -1
  8. data/Gemfile.ruby266 +3 -0
  9. data/Gemfile.ruby266.lock +12 -2
  10. data/README.md +41 -3
  11. data/Rakefile +34 -19
  12. data/features/binary.feature +2 -2
  13. data/features/support/step_definitions/custom_steps.rb +10 -0
  14. data/lib/spreewald.rb +1 -0
  15. data/lib/spreewald/email_steps.rb +3 -1
  16. data/lib/spreewald/frame_steps.rb +77 -0
  17. data/lib/spreewald_support/mail_finder.rb +6 -10
  18. data/lib/spreewald_support/mail_to_plaintext_converter.rb +42 -0
  19. data/lib/spreewald_support/unsupported_email_header.rb +22 -0
  20. data/lib/spreewald_support/version.rb +1 -1
  21. data/spec/spreewald_support/mail_to_plaintext_converter_spec.rb +60 -0
  22. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Gemfile +1 -1
  23. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Gemfile.lock +14 -16
  24. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/README.rdoc +0 -0
  25. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/Rakefile +0 -0
  26. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/app +0 -0
  27. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/bundle +0 -0
  28. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/rails +0 -0
  29. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/rake +0 -0
  30. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/bin/setup +0 -0
  31. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config.ru +0 -0
  32. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/application.rb +0 -0
  33. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/boot.rb +0 -0
  34. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/cucumber.yml +0 -0
  35. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/database.yml +0 -0
  36. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environment.rb +0 -0
  37. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environments/development.rb +0 -0
  38. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/environments/test.rb +0 -0
  39. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/backtrace_silencers.rb +0 -0
  40. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/cookies_serializer.rb +0 -0
  41. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/filter_parameter_logging.rb +0 -0
  42. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/inflections.rb +0 -0
  43. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/mime_types.rb +0 -0
  44. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/session_store.rb +0 -0
  45. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/silence_deprecation_warnings.rb +0 -0
  46. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/to_time_preserves_timezone.rb +0 -0
  47. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/initializers/wrap_parameters.rb +0 -0
  48. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/locales/en.yml +0 -0
  49. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/config/routes.rb +0 -0
  50. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/config/secrets.yml +0 -0
  51. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/db +0 -0
  52. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/browser_tab_steps.feature +0 -0
  53. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/development_steps.feature +0 -0
  54. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/email_steps.feature +0 -0
  55. data/tests/rails-4_capybara-2/features/iframe_steps.feature +1 -0
  56. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/overriding.feature +0 -0
  57. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/session_steps.feature +0 -0
  58. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/overriding_steps.rb +0 -0
  59. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/step_definitions/test_steps.rb +0 -0
  60. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/support/env.rb +0 -0
  61. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/features/support/paths.rb +0 -0
  62. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/features/support/selectors.rb +0 -0
  63. data/tests/rails-4_capybara-2/features/support/selenium.rb +1 -0
  64. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/table_steps.feature +0 -0
  65. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/time_steps.feature +0 -0
  66. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/features/web_steps.feature +0 -0
  67. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/lib/tasks/cucumber.rake +0 -0
  68. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/log/.keep +0 -0
  69. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/404.html +0 -0
  70. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/422.html +0 -0
  71. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/500.html +0 -0
  72. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/favicon.ico +0 -0
  73. data/tests/{rails-4_capybara-3 → rails-4_capybara-2}/public/fixture_files +0 -0
  74. data/tests/{rails-3_capybara-1 → rails-4_capybara-2}/script/cucumber +0 -0
  75. data/tests/rails-6_capybara-3/Gemfile.lock +2 -2
  76. data/tests/rails-6_capybara-3/features/iframe_steps.feature +1 -0
  77. data/tests/rails-6_capybara-3/features/support/selenium.rb +1 -0
  78. data/tests/shared/app/controllers/iframes_controller.rb +11 -0
  79. data/tests/shared/app/controllers/static_pages_controller.rb +12 -8
  80. data/tests/shared/app/views/iframes/iframe_1_content.haml +12 -0
  81. data/tests/shared/app/views/iframes/iframe_2_content.haml +12 -0
  82. data/tests/shared/app/views/static_pages/iframe.haml +3 -0
  83. data/tests/shared/config/routes.rb +4 -0
  84. data/tests/shared/features/shared/email_steps.feature +64 -0
  85. data/tests/shared/features/shared/iframe_steps.feature +38 -0
  86. data/tests/shared/features/shared/step_definitions/test_steps.rb +5 -6
  87. data/tests/shared/features/support/selenium.rb +10 -0
  88. metadata +128 -183
  89. data/.travis.yml +0 -29
  90. data/Gemfile.ruby218 +0 -7
  91. data/Gemfile.ruby218.lock +0 -58
  92. data/tests/rails-3_capybara-1/.ruby-version +0 -1
  93. data/tests/rails-3_capybara-1/Gemfile +0 -20
  94. data/tests/rails-3_capybara-1/Gemfile.lock +0 -182
  95. data/tests/rails-3_capybara-1/Rakefile +0 -18
  96. data/tests/rails-3_capybara-1/app +0 -1
  97. data/tests/rails-3_capybara-1/config.ru +0 -4
  98. data/tests/rails-3_capybara-1/config/application.rb +0 -29
  99. data/tests/rails-3_capybara-1/config/boot.rb +0 -15
  100. data/tests/rails-3_capybara-1/config/cucumber.yml +0 -1
  101. data/tests/rails-3_capybara-1/config/database.yml +0 -1
  102. data/tests/rails-3_capybara-1/config/environment.rb +0 -7
  103. data/tests/rails-3_capybara-1/config/initializers/backtrace_silencers.rb +0 -9
  104. data/tests/rails-3_capybara-1/config/initializers/inflections.rb +0 -12
  105. data/tests/rails-3_capybara-1/config/initializers/mime_types.rb +0 -7
  106. data/tests/rails-3_capybara-1/config/initializers/secret_token.rb +0 -9
  107. data/tests/rails-3_capybara-1/config/initializers/session_store.rb +0 -5
  108. data/tests/rails-3_capybara-1/db +0 -1
  109. data/tests/rails-3_capybara-1/features/shared +0 -1
  110. data/tests/rails-3_capybara-1/features/support/env.rb +0 -65
  111. data/tests/rails-3_capybara-1/features/support/selenium.rb +0 -3
  112. data/tests/rails-3_capybara-1/public +0 -1
  113. data/tests/rails-3_capybara-1/script/rails +0 -6
  114. data/tests/rails-3_capybara-2/.ruby-version +0 -1
  115. data/tests/rails-3_capybara-2/Gemfile +0 -21
  116. data/tests/rails-3_capybara-2/Gemfile.lock +0 -191
  117. data/tests/rails-3_capybara-2/Rakefile +0 -1
  118. data/tests/rails-3_capybara-2/app +0 -1
  119. data/tests/rails-3_capybara-2/config +0 -1
  120. data/tests/rails-3_capybara-2/config.ru +0 -1
  121. data/tests/rails-3_capybara-2/db +0 -1
  122. data/tests/rails-3_capybara-2/features +0 -1
  123. data/tests/rails-3_capybara-2/public +0 -1
  124. data/tests/rails-3_capybara-2/script +0 -1
  125. data/tests/rails-4_capybara-3/config/routes.rb +0 -1
  126. data/tests/rails-4_capybara-3/features/support/paths.rb +0 -1
  127. data/tests/rails-4_capybara-3/features/support/selectors.rb +0 -1
  128. data/tests/rails-4_capybara-3/features/support/selenium.rb +0 -3
  129. data/tests/rails-4_capybara-3/script/cucumber +0 -10
  130. data/tests/rails-6_capybara-3/features/support/selenium.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a51defb2267ab0f0f6e9123b474e0069758e59eaa3f18cadefdfdb81a5f5760
4
- data.tar.gz: f47297c29b676ee194c1dbc2f335eab608afefa9730e124e8811d4542089031e
3
+ metadata.gz: 6b97388391eda8359eab973a0a92896ee7d10e7fc4db749b7f22fb326eddf268
4
+ data.tar.gz: 77aea5e617594133107957b887d5f4848a91532fc46b835b1b5af07164f652e2
5
5
  SHA512:
6
- metadata.gz: 3b93c18acce9d744364898f65e6f3597d06b37ed85d69bb81e3593521d0433bc56338b974c32133c0fce749190ee8af63c146b355e12601397b3641d4424380d
7
- data.tar.gz: b675ad24c9c6e9836880d9111f1538d8f3b5c2d91e390dc5ee5165842cb19298d039fa428405dd47df20daa40b59234f641fcc3e4cab2cf0f6405449ecad981c
6
+ metadata.gz: 43272a84d5e31da1f22426ef84908591696765e4ca394a7ac85ad1d87ffa194aefb7169a104743c162f79b4ab4e9048966c760a51741be2e78d29d3263a3760a
7
+ data.tar.gz: 4bb7a38423937d4b5675dfdff73c3309632d7400152389b9e0617f178be076cd156234e7519faa71f97df7bc90a386c5cd87858cb9a96e6ea1c1f163c468dd30
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: Tests
3
+ 'on':
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-20.04
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ include:
17
+ # Test projects
18
+ - ruby: 2.4.5
19
+ gemfile: tests/rails-4_capybara-2/Gemfile
20
+ - ruby: 2.6.6
21
+ gemfile: tests/rails-6_capybara-3/Gemfile
22
+ # Used to run rspec and integration tests for spreewald binary:
23
+ - ruby: 2.4.5
24
+ gemfile: Gemfile.ruby245
25
+ - ruby: 2.6.6
26
+ gemfile: Gemfile.ruby266
27
+ env:
28
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - name: Install ruby
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: "${{ matrix.ruby }}"
35
+ - name: Bundle
36
+ run: |
37
+ gem install bundler:1.17.3
38
+ bundle install --no-deployment
39
+ - name: Run tests
40
+ run: bundle exec rake matrix:single_test[${{ matrix.gemfile }},${{ matrix.ruby }}]
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## 4.0.0
7
+
8
+ - Dropped support for capybara 1, Ruby 2.1 and Rails 3.2.
9
+
6
10
  ## 3.0.3
7
11
 
8
12
  - The `an email should have been sent with` step now interprets all lines as body when not specifying headers (see issue [#157](https://github.com/makandra/spreewald/issues/157))
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
- gem 'gemika'
4
+ gem 'gemika'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- gemika (0.4.0)
4
+ gemika (0.5.0)
5
5
  rake (12.3.2)
6
6
 
7
7
  PLATFORMS
@@ -12,4 +12,4 @@ DEPENDENCIES
12
12
  rake
13
13
 
14
14
  BUNDLED WITH
15
- 1.17.3
15
+ 2.2.14
data/Gemfile.ruby245 CHANGED
@@ -1,7 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'rake'
3
4
  gem 'rspec'
4
5
  gem 'cucumber'
5
6
  gem 'aruba'
6
7
 
7
8
  gem 'gemika'
9
+ gem 'mail'
10
+ gem 'nokogiri'
data/Gemfile.ruby245.lock CHANGED
@@ -31,10 +31,16 @@ GEM
31
31
  cucumber-wire (0.0.1)
32
32
  diff-lcs (1.3)
33
33
  ffi (1.10.0)
34
- gemika (0.3.4)
34
+ gemika (0.5.0)
35
35
  gherkin (5.1.0)
36
+ mail (2.7.1)
37
+ mini_mime (>= 0.1.1)
38
+ mini_mime (1.0.1)
39
+ mini_portile2 (2.4.0)
36
40
  multi_json (1.13.1)
37
41
  multi_test (0.1.2)
42
+ nokogiri (1.10.10)
43
+ mini_portile2 (~> 2.4.0)
38
44
  rake (12.3.2)
39
45
  rspec (3.8.0)
40
46
  rspec-core (~> 3.8.0)
@@ -58,6 +64,9 @@ DEPENDENCIES
58
64
  aruba
59
65
  cucumber
60
66
  gemika
67
+ mail
68
+ nokogiri
69
+ rake
61
70
  rspec
62
71
 
63
72
  BUNDLED WITH
data/Gemfile.ruby266 CHANGED
@@ -2,8 +2,11 @@ source 'https://rubygems.org'
2
2
 
3
3
  ruby '2.6.6'
4
4
 
5
+ gem 'rake'
5
6
  gem 'rspec'
6
7
  gem 'cucumber'
7
8
  gem 'aruba'
8
9
 
9
10
  gem 'gemika'
11
+ gem 'mail'
12
+ gem 'nokogiri'
data/Gemfile.ruby266.lock CHANGED
@@ -30,10 +30,17 @@ GEM
30
30
  cucumber-wire (0.0.1)
31
31
  diff-lcs (1.3)
32
32
  ffi (1.12.2)
33
- gemika (0.4.0)
33
+ gemika (0.5.0)
34
34
  gherkin (5.1.0)
35
+ mail (2.7.1)
36
+ mini_mime (>= 0.1.1)
37
+ mini_mime (1.0.2)
35
38
  multi_json (1.14.1)
36
39
  multi_test (0.1.2)
40
+ nokogiri (1.11.1-x86_64-linux)
41
+ racc (~> 1.4)
42
+ racc (1.5.2)
43
+ rake (13.0.3)
37
44
  rspec (3.9.0)
38
45
  rspec-core (~> 3.9.0)
39
46
  rspec-expectations (~> 3.9.0)
@@ -56,10 +63,13 @@ DEPENDENCIES
56
63
  aruba
57
64
  cucumber
58
65
  gemika
66
+ mail
67
+ nokogiri
68
+ rake
59
69
  rspec
60
70
 
61
71
  RUBY VERSION
62
72
  ruby 2.6.6p146
63
73
 
64
74
  BUNDLED WITH
65
- 2.1.4
75
+ 2.2.14
data/README.md CHANGED
@@ -19,9 +19,9 @@ Or install it yourself as:
19
19
  $ gem install spreewald
20
20
 
21
21
 
22
- ## Supported RSpec versions
22
+ ## Supported versions
23
23
 
24
- Spreewald supports RSpec >= 2.13.0
24
+ Spreewald is currently tested against Ruby 2.4.5 with Rails 4 and Capybara 2 and Ruby 2.6.6 with Rails 6 and Capybara 3.
25
25
 
26
26
  ## Usage
27
27
 
@@ -237,7 +237,9 @@ the step definitions.
237
237
 
238
238
  """
239
239
 
240
- You may skip lines in the header, of course.
240
+ You may skip lines in the header.
241
+ Please note: In older versions of Spreewald, unmentioned body lines were skipped.
242
+ Now you have to use the asterisk explicitly to omit lines in the body.
241
243
 
242
244
 
243
245
  * **When I follow the (first|second|third)? link in the e?mail**
@@ -265,6 +267,42 @@ the step definitions.
265
267
  This uses the same syntax as `Then an email should have been sent with:`
266
268
 
267
269
 
270
+ ### frame_steps.rb
271
+
272
+ * **When ... inside the ... iframe**
273
+
274
+ You can append `inside the [name or number] iframe` to any other step.
275
+ Then the step will operate inside the given iframe.
276
+ Examples:
277
+
278
+ Then I should see "Kiwi" inside the 1st iframe
279
+ Then I should see "Cherry" inside the fruits iframe
280
+ When I press "Save" inside the 2nd iframe
281
+
282
+
283
+
284
+ * **When I switch to the ... iframe**
285
+
286
+ This step will switch to the iframe identified by its name or number.
287
+ All further steps will operate inside the iframe.
288
+ To switch to operating on the main page again, use the step
289
+ "I switch back to the whole page".
290
+ Examples:
291
+
292
+ When I switch to the 1st iframe
293
+ When I switch to the fruits iframe
294
+
295
+ Please note: This step is only available for Capybara >= 3.
296
+
297
+
298
+ * **When I switch back to the whole page**
299
+
300
+ This step can be used to switch back to the whole page if you switched
301
+ to operating inside an iframe before (step `I switch to the ... iframe`)
302
+
303
+ Please note: This step is only available for Capybara >= 3.
304
+
305
+
268
306
  ### session_steps.rb
269
307
 
270
308
  * **When ... in the browser session "..."**
data/Rakefile CHANGED
@@ -10,28 +10,25 @@ end
10
10
  task :default => 'matrix:tests'
11
11
 
12
12
  namespace :matrix do
13
+ desc 'Run tests for a single row of the matrix'
14
+ task :single_test, [:gemfile, :ruby] do |_t, args|
15
+ gemfile = args[:gemfile]
16
+ ruby = args[:ruby]
13
17
 
14
- desc "Run all tests which are available for current Ruby (#{RUBY_VERSION})"
15
- task :tests do
16
- Gemika::Matrix.from_travis_yml.each do |row|
17
- directory = File.dirname(row.gemfile)
18
- if directory.start_with?('tests')
19
- # Run integration tests (uses embedded projects)
20
- system(cucumber_command(directory, row.ruby))
21
- else
22
- # Run specs and tests for spreewald binary
23
- [
24
- system("BUNDLE_GEMFILE=#{row.gemfile} bundle exec rspec"),
25
- system("BUNDLE_GEMFILE=#{row.gemfile} bundle exec cucumber"),
26
- ].all?
27
- end
18
+ if gemfile.nil? || ruby.nil?
19
+ warn 'Please state the Gemfile and Ruby version to be used for the Testrun!'
20
+ else
21
+ run_tests(gemfile, ruby)
28
22
  end
29
-
30
- travis_yml = YAML.load_file('.travis.yml')
31
- rubies = travis_yml.fetch('rvm') - [RUBY_VERSION]
32
- puts "Please remember to run tests for the other ruby versions as well: #{rubies.join(", ")}"
33
23
  end
34
24
 
25
+
26
+ desc "Run all tests which are available for current Ruby (#{RUBY_VERSION})"
27
+ task :tests, [:gemfile, :ruby] do |_t, args|
28
+ Gemika::Matrix.from_ci_config.each do |row|
29
+ run_tests(row.gemfile, row.ruby)
30
+ end
31
+ end
35
32
  end
36
33
 
37
34
 
@@ -59,12 +56,30 @@ task :update_readme do
59
56
  puts '', '> Done (diff applied).'
60
57
  end
61
58
 
59
+ def run_tests(gemfile, ruby)
60
+ directory = File.dirname(gemfile)
61
+ if directory.start_with?('tests')
62
+ # Run integration tests (uses embedded projects)
63
+ system(cucumber_command(directory, ruby))
64
+ else
65
+ # Run specs and integration tests for Spreewald binary
66
+ [
67
+ system("BUNDLE_GEMFILE=#{gemfile} bundle exec rspec"),
68
+ system("BUNDLE_GEMFILE=#{gemfile} bundle exec cucumber"),
69
+ ].all?
70
+ end
71
+ end
72
+
62
73
  def cucumber_command(directory, ruby_version)
63
- command = "cd #{directory} && BUNDLE_GEMFILE=Gemfile geordi cucumber"
74
+ command = "cd #{directory} && BUNDLE_GEMFILE=Gemfile bundle exec cucumber"
64
75
  if Gem::Version.new(ruby_version) > Gem::Version.new('2.5')
65
76
  # Modern cucumber sees pending tests as failures.
66
77
  # We don't want this.
67
78
  command << ' --no-strict-pending'
79
+ else
80
+ # Ruby < 2.5 means the capybara 2 Test project.
81
+ # Omit scenarios that only work with modern Capybara.
82
+ command << ' --tags "not @not-capybara-2"'
68
83
  end
69
84
  command
70
85
  end
@@ -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"
@@ -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,16 +1,20 @@
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
@@ -63,15 +67,7 @@ class MailFinder
63
67
  end
64
68
 
65
69
  def email_text_body(mail, type = '')
66
- body = if mail.html_part && type != 'plain-text'
67
- dom = Nokogiri::HTML(mail.html_part.body.to_s)
68
- dom.at_css('body').text.gsub(/[\r\n]+/, "\n")
69
- elsif mail.text_part && type != 'HTML'
70
- mail.text_part.body.to_s
71
- else
72
- mail.body.to_s
73
- end
74
- 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
75
71
  end
76
72
 
77
73
  def show_mails(mails, only_header = false)