spreewald 4.6.1 → 4.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 256b5e48d9fcbb9c845bc5f8503475a10184d2356f5483307100b43c7ae1a504
4
- data.tar.gz: 9374a61e063de94a0b240b24c8f48b292f95d87adc285b9893b3bc2a3d725c2d
3
+ metadata.gz: f21efaeee956e332f09bf91655335cfc24bcf5f5a46403c11ea6fa4d2f390b25
4
+ data.tar.gz: '09cae0432a1190dbfc515456705b6977ca4320c688e46ee5e1307a8ca07f9f69'
5
5
  SHA512:
6
- metadata.gz: 934b5123e15812171d3d3dd1cf9f477024ac8f217b612ac85d6cf165afbd535fb2fd052755e52d389804c1f2b4222bce2c59259dfea1af771d367352e6d1baa8
7
- data.tar.gz: 837aa75e2071c48ccca0855746d86c1f4a205be84d15ba8a4c569036f56f51fb940700c1cdf362f253a66acb96b29e467e9353255ec6244501ce9cff1c9df6a8
6
+ metadata.gz: 295f1e8f0ea1b1b544d622005e020b8ba168eb27612077d55a58613162eb4ee65c0e32ba287ddef7f0fc58408817f48c3093e9b6c8ff94603076de3878ceccfc
7
+ data.tar.gz: d7ab22c6640d44c85c5b18f7c9e1028194eadd284d872aedf8ed56c64423a2e0409e8e545b2fbacf782d89ef219292797a5dc7a583494dcd5ce54c7bb7790399
data/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@ 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.6.3
7
+ - Fix email steps not showing the attachments
8
+
9
+ ## 4.6.2
10
+ - Fix uninitialized constant `XPath::HTML` when using `When I fill in "..." with "..." inside any "..."` ([#210](https://github.com/makandra/spreewald/issues/210))
11
+
6
12
  ## 4.6.1
7
13
  - Fix undefined method `irb_at_exit` in new IRB versions ([#208](https://github.com/makandra/spreewald/pull/208))
8
14
 
data/Gemfile.ruby266.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spreewald (4.6.1)
4
+ spreewald (4.6.3)
5
5
  capybara
6
6
  cucumber
7
7
  cucumber_priority (>= 0.3.0)
data/Gemfile.ruby320.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spreewald (4.6.1)
4
+ spreewald (4.6.3)
5
5
  capybara
6
6
  cucumber
7
7
  cucumber_priority (>= 0.3.0)
data/README.md CHANGED
@@ -211,6 +211,10 @@ the step definitions.
211
211
 
212
212
  ### email_steps.rb
213
213
 
214
+ When specifying the `to`, `cc`, `bcc`, `from` or `reply_to` targets within email steps, you can either specify email addresses or any arbitrary identifier. When an identifier (other than an email address) is given, Spreewald can try to use this information to determine the associated user and gather its email address automatically over the application's `User` model. For this, you may set `Spreewald::MailFinder.user_identity` to an attribute name and Spreewald will call `User.find_by_<user_identity>(identifier)` and then use the `email` of the found user.<br/>
215
+
216
+ For example, if you set `reply_to` to the name `John Doe` within a scenario step and specify `Spreewald::MailFinder.user_identity = 'name'`, Spreewald will call `User.find_by_name('John Doe')`, find the according user with this name and expect its email address as `reply_to`.
217
+
214
218
  * **When I clear my e?mails**
215
219
 
216
220
 
@@ -568,7 +572,11 @@ deprecation notice. Decide for yourself whether you want to use them:
568
572
 
569
573
  * **Then the "..." field should have the error "..."**
570
574
 
571
- Checks that an input field was wrapped with a validation error
575
+ Checks that an input field was wrapped with a validation error. This is done by checking for different error HTML structures that display errors.<br/><br/>
576
+
577
+ Spreewald first checks for custom error wrappers (if specified), then Boostrap 3 error wrappers (`.form-group.has-error`), then Bootstrap 4/5 error wrappers (`:invalid` or `is-invalid`) and lastly, Rails error wrappers (`field_with_errors`). You are able to specify a custom error wrapper by setting `Spreewald.field_error_class = 'my-custom-error-class'` which is then used to look for the error class on the current or any ancestor `div`.<br /><br />
578
+
579
+ The same principle applies for matching the error message. First, it will look for the message text (starting from the input element) with a custom XPath (if specified), then one targeting a sibling element with a `help-block` class for Bootstrap 3 and then one targeting a sibling element with an `invalid-feedback` class for Bootstrap 4/5. Rails errors are checked specifically over the field title as this one contains the error message. You may specify the custom XPath by setting (e.g.) `Spreewald.error_message_xpath_selector = 'parent::*/child::*[@class="my-error-message"]'`.
572
580
 
573
581
 
574
582
  * **Then the "..." field should( not)? have an error**
@@ -620,7 +620,9 @@ When /^I fill in "([^"]*)" with "([^"]*)" inside any "([^"]*)"$/ do |field, valu
620
620
  containers = all(:css, selector)
621
621
  input = nil
622
622
  containers.detect do |container|
623
- input = container.first(:xpath, XPath::HTML.fillable_field(field))
623
+ input = container.first(:fillable_field, field)
624
+ rescue Capybara::ElementNotFound
625
+ # Capybara changed the behavior of #first and raises an error when the first container finds no matching field
624
626
  end
625
627
  if input
626
628
  input.set(value)
@@ -24,7 +24,6 @@ class MailFinder
24
24
  body = [header, body].join("\n\n")
25
25
  end
26
26
 
27
- filename_method = Rails::VERSION::MAJOR < 3 ? 'original_filename' : 'filename'
28
27
  matching_header = ActionMailer::Base.deliveries.select do |mail|
29
28
  [ conditions[:to].nil? || mail.to.include?(resolve_email conditions[:to]),
30
29
  conditions[:cc].nil? || mail.cc && mail.cc.include?(resolve_email conditions[:cc]),
@@ -32,7 +31,7 @@ class MailFinder
32
31
  conditions[:from].nil? || mail.from.include?(resolve_email conditions[:from]),
33
32
  conditions[:reply_to].nil? || mail.reply_to.include?(resolve_email conditions[:reply_to]),
34
33
  conditions[:subject].nil? || mail.subject.include?(conditions[:subject]),
35
- conditions[:attachments].nil? || conditions[:attachments].split(/\s*,\s*/).sort == Array(mail.attachments).collect(&:"#{filename_method}").sort
34
+ conditions[:attachments].nil? || conditions[:attachments].split(/\s*,\s*/).sort == attachment_filenames(mail)
36
35
  ].all?
37
36
  end
38
37
 
@@ -64,6 +63,9 @@ class MailFinder
64
63
  header << "CC: #{mail.cc.join(', ')}\n" if mail.cc
65
64
  header << "BCC: #{mail.bcc.join(', ')}\n" if mail.bcc
66
65
  header << "Subject: #{mail.subject}\n"
66
+ header << "Attachments: #{attachment_filenames(mail).join(', ')}\n" if mail.attachments.any?
67
+
68
+ header
67
69
  end
68
70
 
69
71
  def email_text_body(mail, type = '')
@@ -94,6 +96,12 @@ class MailFinder
94
96
  Regexp.new(expected)
95
97
  end
96
98
 
99
+ private
100
+
101
+ def attachment_filenames(mail)
102
+ Array(mail.attachments).collect(&:filename).sort
103
+ end
104
+
97
105
  end
98
106
  end
99
107
 
@@ -1,3 +1,3 @@
1
1
  module Spreewald
2
- VERSION = '4.6.1'
2
+ VERSION = '4.6.3'
3
3
  end
@@ -93,4 +93,26 @@ describe Spreewald::Steps::ShowMeTheMails do
93
93
  expect { step.run }.to output(expected_output).to_stdout
94
94
  end
95
95
  end
96
+
97
+ context "with attachments" do
98
+ it 'includes the filenames of the attachments' do
99
+ mail = Mail.new do
100
+ attachments['attached_file.pdf'] = File.open("tests/shared/public/fixture_files/attachment.pdf") {}
101
+ attachments['other_attached_file.pdf'] = File.open("tests/shared/public/fixture_files/attachment.pdf") {}
102
+ end
103
+
104
+ expected_output = <<~TXT
105
+ E-Mail #0
106
+ --------------------------------------------------------------------------------
107
+ From:
108
+ Subject:
109
+ Attachments: attached_file.pdf, other_attached_file.pdf
110
+ --------------------------------------------------------------------------------
111
+
112
+ TXT
113
+ step = Spreewald::Steps::ShowMeTheMails.new([mail], true)
114
+ expect { step.run }.to output(expected_output).to_stdout
115
+ end
116
+ end
117
+
96
118
  end
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.2.0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (4.6.1)
4
+ spreewald (4.6.3)
5
5
  capybara
6
6
  cucumber
7
7
  cucumber_priority (>= 0.3.0)
@@ -67,14 +67,7 @@ class EmailsController < ApplicationController
67
67
  private
68
68
 
69
69
  def deliver(method_name)
70
- case
71
- when Rails.version.to_i >= 5
72
- SpreewaldMailer.send(method_name).deliver
73
- when Rails.version.to_i >= 3
74
- Mailer.public_send(method_name).deliver
75
- else
76
- Mailer.public_send("deliver_#{method_name}")
77
- end
70
+ SpreewaldMailer.send(method_name).deliver
78
71
  end
79
72
 
80
73
  end
@@ -12,6 +12,9 @@ class FormsController < ApplicationController
12
12
  def form2
13
13
  end
14
14
 
15
+ def form_with_two_inputs_in_separate_css_blocks_with_the_same_selector
16
+ end
17
+
15
18
  def select_fields
16
19
  end
17
20
 
@@ -7,113 +7,60 @@ class Mailer < ActionMailer::Base
7
7
  FROM = "from@example.com"
8
8
  SUBJECT = "SUBJECT"
9
9
 
10
- if Rails.version >= "3"
11
-
12
- def email
13
- attachments['attached_file.pdf'] = File.open("#{Rails.root}/public/fixture_files/attachment.pdf", "w") {}
14
- mail(
15
- :from => FROM,
16
- :reply_to => REPLY_TO,
17
- :to => TO,
18
- :cc => CC,
19
- :bcc => BCC,
20
- :subject => SUBJECT
21
- )
22
- end
23
-
24
- def email_crlf
25
- email
26
- end
27
-
28
- def email_with_umlauts
29
- email
30
- end
31
-
32
- def html_email_with_links
33
- email
34
- end
35
-
36
- def text_email_with_links
37
- email
38
- end
39
-
40
- def html_email_with_linebreaks
41
- email
42
- end
43
-
44
- def html_email_with_specific_line
45
- email
46
- end
47
-
48
- def text_email_with_specific_line
49
- email
50
- end
51
-
52
- def html_email_for_successful_test_without_header
53
- email
54
- end
55
-
56
- def text_email_for_successful_test_without_header
57
- email
58
- end
59
-
60
- def html_email_for_failed_test_without_header
61
- email
62
- end
63
-
64
- def text_email_for_failed_test_without_header
65
- email
66
- end
67
-
68
- else
10
+ def email
11
+ attachments['attached_file.pdf'] = File.open("#{Rails.root}/public/fixture_files/attachment.pdf") {}
12
+ mail(
13
+ :from => FROM,
14
+ :reply_to => REPLY_TO,
15
+ :to => TO,
16
+ :cc => CC,
17
+ :bcc => BCC,
18
+ :subject => SUBJECT
19
+ )
20
+ end
69
21
 
70
- def email
71
- attachments['attached_file.pdf'] = File.open("#{Rails.root}/public/fixture_files/attachment.pdf", "w") {}
72
- recipients TO
73
- reply_to REPLY_TO
74
- from FROM
75
- cc CC
76
- bcc BCC
77
- subject SUBJECT
78
- body BODY
79
- end
22
+ def email_crlf
23
+ email
24
+ end
80
25
 
81
- def email_crlf
82
- email
83
- end
26
+ def email_with_umlauts
27
+ email
28
+ end
84
29
 
85
- def html_email_with_links
86
- email
87
- end
30
+ def html_email_with_links
31
+ email
32
+ end
88
33
 
89
- def text_email_with_links
90
- email
91
- end
34
+ def text_email_with_links
35
+ email
36
+ end
92
37
 
93
- def html_email_with_specific_line
94
- email
95
- end
38
+ def html_email_with_linebreaks
39
+ email
40
+ end
96
41
 
97
- def text_email_with_specific_line
98
- email
99
- end
42
+ def html_email_with_specific_line
43
+ email
44
+ end
100
45
 
101
- def html_email_for_successful_test_without_header
102
- email
103
- end
46
+ def text_email_with_specific_line
47
+ email
48
+ end
104
49
 
105
- def text_email_for_successful_test_without_header
106
- email
107
- end
50
+ def html_email_for_successful_test_without_header
51
+ email
52
+ end
108
53
 
109
- def html_email_for_failed_test_without_header
110
- email
111
- end
54
+ def text_email_for_successful_test_without_header
55
+ email
56
+ end
112
57
 
113
- def text_email_for_failed_test_without_header
114
- email
115
- end
58
+ def html_email_for_failed_test_without_header
59
+ email
60
+ end
116
61
 
62
+ def text_email_for_failed_test_without_header
63
+ email
117
64
  end
118
65
 
119
66
  end
@@ -0,0 +1,8 @@
1
+ = form_tag do
2
+ .my-container
3
+ = label_tag 'first_text_field', 'First Text field'
4
+ = text_field_tag 'first_text_field', 'First value'
5
+
6
+ .my-container
7
+ = label_tag 'second_text_field', 'Second Text field'
8
+ = text_field_tag 'second_text_field', 'Second value'
@@ -22,6 +22,7 @@ Rails.application.routes.draw do
22
22
  get '/forms/disabled_elements', to: 'forms#disabled_elements'
23
23
  get '/forms/form1', to: 'forms#form1'
24
24
  get '/forms/form2', to: 'forms#form2'
25
+ get '/forms/form_with_two_inputs_in_separate_css_blocks_with_the_same_selector', to: 'forms#form_with_two_inputs_in_separate_css_blocks_with_the_same_selector'
25
26
  get '/forms/select_fields', to: 'forms#select_fields'
26
27
  get '/forms/invalid_rails_form', to: 'forms#invalid_rails_form'
27
28
  get '/forms/invalid_bootstrap3_form', to: 'forms#invalid_bootstrap3_form'
@@ -297,6 +297,24 @@ Feature: Test Spreewald's email steps
297
297
  '''
298
298
  """
299
299
 
300
+ Then the following multiline step should succeed:
301
+ """
302
+ Then an email should have been sent with:
303
+ '''
304
+ From: from@example.com
305
+ Attachments: attached_file.pdf
306
+ '''
307
+ """
308
+
309
+ Then the following multiline step should fail:
310
+ """
311
+ Then an email should have been sent with:
312
+ '''
313
+ From: from@example.com
314
+ Attachments: not_attached_file.pdf
315
+ '''
316
+ """
317
+
300
318
  When I clear my emails
301
319
  And I go to "/emails/send_crlf_email"
302
320
 
@@ -416,3 +416,13 @@ Feature: Web steps
416
416
  Scenario: /^the window should be titled "([^"]*)"$/
417
417
  When I go to "/static_pages/home"
418
418
  Then the window should be titled "spreewald test application"
419
+
420
+
421
+ Scenario: I fill in "..." with "..." inside any "..."
422
+ When I go to "/forms/form_with_two_inputs_in_separate_css_blocks_with_the_same_selector"
423
+ Then the "First Text field" field should contain "First value"
424
+ And the "Second Text field" field should contain "Second value"
425
+
426
+ When I fill in "Second Text field" with "My new value" inside any ".my-container"
427
+ Then the "First Text field" field should contain "First value"
428
+ And the "Second Text field" field should contain "My new value"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreewald
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.1
4
+ version: 4.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-25 00:00:00.000000000 Z
11
+ date: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -225,6 +225,7 @@ files:
225
225
  - tests/shared/app/views/forms/disabled_elements.html.haml
226
226
  - tests/shared/app/views/forms/form1.html.haml
227
227
  - tests/shared/app/views/forms/form2.html.haml
228
+ - tests/shared/app/views/forms/form_with_two_inputs_in_separate_css_blocks_with_the_same_selector.html.haml
228
229
  - tests/shared/app/views/forms/invalid_bootstrap3_form.html.haml
229
230
  - tests/shared/app/views/forms/invalid_bootstrap4_form.html.haml
230
231
  - tests/shared/app/views/forms/invalid_custom_form.html.haml
@@ -315,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
316
  - !ruby/object:Gem::Version
316
317
  version: '0'
317
318
  requirements: []
318
- rubygems_version: 3.4.20
319
+ rubygems_version: 3.4.1
319
320
  signing_key:
320
321
  specification_version: 4
321
322
  summary: Collection of useful cucumber steps.
@@ -394,6 +395,7 @@ test_files:
394
395
  - tests/shared/app/views/forms/disabled_elements.html.haml
395
396
  - tests/shared/app/views/forms/form1.html.haml
396
397
  - tests/shared/app/views/forms/form2.html.haml
398
+ - tests/shared/app/views/forms/form_with_two_inputs_in_separate_css_blocks_with_the_same_selector.html.haml
397
399
  - tests/shared/app/views/forms/invalid_bootstrap3_form.html.haml
398
400
  - tests/shared/app/views/forms/invalid_bootstrap4_form.html.haml
399
401
  - tests/shared/app/views/forms/invalid_custom_form.html.haml