spreewald 2.8.0 → 3.0.1

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: 59c446ad46ae093a7bb103d7e4959dbbc7e29327cbc30e5730aff221f8488e36
4
- data.tar.gz: e23e4bd833a6234e6ce2b4e6ab104f102708bab13ab54f10aad8b97df08cd39b
3
+ metadata.gz: e94fff73b1219c20c1140b38f45de5a44e57da77eed6ef8fd9107c157a075c37
4
+ data.tar.gz: 0b9dab763d05e9e248c25d3e8cecb1b6493116dfd96e5c6a5c12e9a52ee417ec
5
5
  SHA512:
6
- metadata.gz: 8d7b6e7ddd55b75433d7c800045c09f68b7175646de8a3f9ac11a5741ee83ce39c22d8bb5a8b5d9d77b4d22df01eda5de51093de4a76cabf73ae354308b12abc
7
- data.tar.gz: bc169b566a8878be0ad26b2b1522b960b57772d80d135ffbe4a34476c673282d75b7666d9ccf14a585c229739b3d543620f578c3b59a7e6f62cf036a5df2f90c
6
+ metadata.gz: 8abca9273d361112be92fecbd993efe99664baf70cb30af7a8be91d006fa89cfa9492a89d3b066a9824adde47439dda412ead601e51cd5006bbf8fd3d7185fb0
7
+ data.tar.gz: ce43a7c95abf0bc13b21baa1b23b7c14fbe05e10a7ad705efc1debb03bd7c18251d2b8acfaae38e9882d2f34278d9b8fb96860c1ba2795baf16c6d3a38fa8c7e
@@ -3,6 +3,58 @@ 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
+ ## 3.0.1
7
+
8
+ - Fix deduplication of linebreaks for html mails in mail finder. (see issue [#153](https://github.com/makandra/spreewald/issues/153))
9
+
10
+ ## 3.0.0
11
+
12
+ ### Breaking changes
13
+
14
+ - The following steps have been removed:
15
+ - `/^the file "([^"]*)" was attached(?: as (?:([^"]*)\/)?([^"]*))? to the ([^"]*) above(?: at "([^"]*)")?$/` (see [#106](https://github.com/makandra/spreewald/issues/106), this functionality was moved to [CucumberFactory](https://github.com/makandra/cucumber_factory))
16
+ - `/^the "([^"]*)" field should have no error$/` (see [#134](https://github.com/makandra/spreewald/issues/134))
17
+ - `/^I should get a text response$/` (see [#135](https://github.com/makandra/spreewald/issues/135))
18
+ - `/^I wait for the page to load$/` (see [#136](https://github.com/makandra/spreewald/issues/136))
19
+ - `debugger` (was an alias for `console`)
20
+ - These email steps have been removed in favor of `(an?|no)( HTML| plain-text|) e?mail should have been sent with:` (see [#132](https://github.com/makandra/spreewald/issues/132#issuecomment-631457290)):
21
+ - `/^(an|no) e?mail should have been sent((?: |and|with|from "[^"]+"|bcc "[^"]+"|cc "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/`
22
+ - `/^that e?mail should( not)? have the following lines in the body$/`
23
+ - `/^that e?mail should have the following (?:|content in the )body:$/`
24
+ - The `and disabled` modifier of the step `the "..." checkbox should( not)? be checked` has been removed. Use the step without the modifier together with the step `the "..." checkbox should be disabled` to achieve the old behavior.
25
+ - The step `/^(the tag )?"([^\"]+)" should( not)? be visible$/` lost its `not` modifier (Use `Then (the tag )?"..." should be hidden` or `Then I should not see "..."`)
26
+ - The file `lib/spreewald/timecop_steps.rb` was removed (was an alias for `lib/spreewald/time_steps.rb`).
27
+ - The step `(an?|no)( HTML| plain-text|) e?mail should have been sent with:` does now require that the whole body is matched.
28
+ - All web steps interacting with forms will now find both enabled and disabled fields. We encourage you to assert the "disabled" state in a separate step when needed, Spreewald offers these steps as well.
29
+
30
+ The following steps have been adjusted:
31
+ - `I should( not)? see a field "..."`
32
+ - `the "..." field should( not)? contain "..."`
33
+ - `I should see a form with the following values:`
34
+ - `the "..." field should have the error "..."`
35
+ - `the "..." field should( not)? have an error`
36
+ - `the "..." checkbox should( not)? be checked`
37
+ - `"..." should be selected for "..."`
38
+ - `nothing should be selected for "..."`
39
+ - `"..." should( not)? be an option for "..."`
40
+ - `the "..." field should( not)? be visible`
41
+ - `the "..." select should( not)? be sorted`
42
+
43
+ ### Compatible changes
44
+ - Reintroduced support for emails with CRLF line ending
45
+
46
+ ## 2.99.0
47
+ - The following steps were deprecated and will be removed in the upcoming major version:
48
+ - `/^the "([^"]*)" field should have no error$/` (see [#134](https://github.com/makandra/spreewald/issues/134))
49
+ - `/^I should get a text response$/` (see [#135](https://github.com/makandra/spreewald/issues/135))
50
+ - `/^I wait for the page to load$/` (see [#136](https://github.com/makandra/spreewald/issues/136))
51
+ - The step `and disabled` modifier of the step `/^the "([^"]*)" checkbox should( not)? be checked( and disabled)?$/` has been deprecated.
52
+
53
+ ## 2.9.0
54
+ - The step `an email should have been sent with:` does now support wildcards (`*` at the end of a line to ignore the rest of the line, `*` as single character in a line to ignore multiple lines). The step also has better error messages if an email could not be found.
55
+ - The step `show me the emails` got an option to display only the email headers. Additionally, a new step `show me the email( header)?s with:` has been created to only show a subset of all sent emails, with a syntax similar to `an email should have been sent with:`.
56
+ - The email steps `an email should have been sent (from ...) (to ...) (cc ...) ...`, `that email should( not)? have the following lines in the body` and `that email should have the following content in the body:` have been deprecated in favor of `an email should have been sent with:`.
57
+
6
58
  ## 2.8.0
7
59
  - Add radio buttons to the `the "..." (field|button|checkbox|radio button) should( not)? be disabled` step.
8
60
 
@@ -64,7 +116,7 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
64
116
  * It can now be composed with the 'within' step
65
117
  * It can now truly match negative numbers
66
118
  * It dropped the hidden dependency on the HTMLEntities gem
67
- * Fix URLs to the GitHub repository of Spreewald as part of the `_path_to` and `_selector_for` error handling. (see issue [#82](https://github.com/makandra/spreewald/issues/82))
119
+ * Fix URLs to the GitHub repository of Spreewald as part of the `_path_to` and `_selector_for` error handling. (see issue [#82](https://github.com/makandra/spreewald/issues/82))
68
120
 
69
121
  ## 2.2.0
70
122
  - Add a new step `I should( not)? see a link labeled "STRING"`.
@@ -97,7 +149,7 @@ The "it should work" step now takes an optional reason.
97
149
  The word "within" can now be used in arguments for other steps without causing errors ([Issue #53](https://github.com/makandra/spreewald/issues/80))
98
150
 
99
151
  ## 1.12.3
100
- Prevent wall of warnings when `Then console` is used multiple times in on test run ([issue](https://github.com/makandra/spreewald/issues/80))
152
+ Prevent wall of warnings when `Then console` is used multiple times in on test run ([issue](https://github.com/makandra/spreewald/issues/80))
101
153
 
102
154
  ## 1.12.2
103
155
  Always check the current driver by its class (see [issue](https://github.com/makandra/spreewald/issues/74))
@@ -111,4 +163,3 @@ Always check the current driver by its class (see [issue](https://github.com/mak
111
163
  ## 1.11.6 2018-08-28
112
164
  - Added CHANGELOG
113
165
  - Replaced `field_labeled` with `find_field` (https://github.com/teamcapybara/capybara/blob/master/History.md#removed)
114
-
data/README.md CHANGED
@@ -197,8 +197,7 @@ the step definitions.
197
197
  * **Then console**
198
198
 
199
199
  Pauses test execution and opens an IRB shell with current context. Does not halt the application-
200
- under-test. (Replaces the "Then debugger" step that has never been adequate
201
- for its job)
200
+ under-test.
202
201
 
203
202
 
204
203
  * **AfterStep @slow-motion**
@@ -216,7 +215,7 @@ the step definitions.
216
215
  * **When I clear my e?mails**
217
216
 
218
217
 
219
- * **Then (an|no) e?mail should have been sent with:**
218
+ * **Then (an?|no)( HTML| plain-text|) e?mail should have been sent with:**
220
219
 
221
220
  Example:
222
221
 
@@ -225,24 +224,20 @@ the step definitions.
225
224
  From: max.mustermann@example.com
226
225
  Reply-To: mmuster@gmail.com
227
226
  To: john.doe@example.com
227
+ CC: jane.doe@example.com
228
+ BCC: johnny.doe@example.com
228
229
  Subject: The subject may contain "quotes"
229
- Attachments: ...
230
+ Attachments: image.jpg, attachment.pdf
230
231
 
231
- Message body goes here.
232
- """
233
-
234
- You may skip lines in the header, of course. Note that the mail body is only checked for
235
- _inclusion_. That means you can only test a prefix of the body. The subject may also be
236
- a prefix.
237
-
238
-
239
- * **Then (an|no) e?mail should have been sent(( |and|with|from "..."|bcc "..."|cc "..."|to "..."|the subject "..."|the body "..."|the attachments "...")+)**
240
-
241
- Example:
232
+ This is the message body. You can use * as a wildcard to omit the rest
233
+ of a line *
234
+ Or you can omit multiple lines if the asterisk is the only
235
+ character in a single line, like this:
236
+ *
242
237
 
243
- Then an email should have been sent from "max.mustermann@example.com" to "john.doe@example.com" with bcc "john.wane@example.com" and with cc "foo@bar.com" and the subject "The subject" and the body "The body" and the attachments "attachment.pdf"
238
+ """
244
239
 
245
- You may skip parts, of course.
240
+ You may skip lines in the header, of course.
246
241
 
247
242
 
248
243
  * **When I follow the (first|second|third)? link in the e?mail**
@@ -254,39 +249,20 @@ the step definitions.
254
249
  * **Then no e?mail should have been sent**
255
250
 
256
251
 
257
- * **Then I should see "..." in the e?mail**
252
+ * **Then I should see "..." in the( HTML| plain-text|) e?mail**
258
253
 
259
254
  Checks that the last sent email includes some text
260
255
 
261
256
 
262
- * **Then show me the e?mails**
263
-
264
- Print all sent emails to STDOUT.
265
-
266
-
267
- * **Then that e?mail should( not)? have the following lines in the body:**
268
-
269
- Example:
270
-
271
- And that mail should have the following lines in the body:
272
- """
273
- All of these lines
274
- need to be present
275
- """
276
-
277
- You may skip lines, of course. Note that you may also omit text at the end of each line.
257
+ * **Then show me the e?mail( header)?s**
278
258
 
259
+ Print all sent emails to STDOUT (optionally only the headers).
279
260
 
280
- * **Then that e?mail should have the following (|content in the )body:**
281
261
 
282
- Checks that the text should be included anywhere in the retrieved email body
262
+ * **Then show me the e?mail( header)?s with:**
283
263
 
284
-
285
- ### file_attachment_steps.rb
286
-
287
- * **Given the file "..." was attached( as (.../)?...)? to the ... above( at "...")?**
288
-
289
- This step is deprecated and will be removed from spreewald. If you still want to use it, copy the code to your project's own steps.
264
+ Print a subset of all sent emails to STDOUT
265
+ This uses the same syntax as `Then an email should have been sent with:`
290
266
 
291
267
 
292
268
  ### session_steps.rb
@@ -343,8 +319,6 @@ Please note that the two approaches branch. While ActiveSupport will freeze the
343
319
  When it is a few hours earlier
344
320
 
345
321
 
346
-
347
-
348
322
  ### web_steps.rb
349
323
 
350
324
  Most of cucumber-rails' original web steps plus a few of our own.
@@ -572,10 +546,7 @@ deprecation notice. Decide for yourself whether you want to use them:
572
546
  * **Then the "..." field should( not)? have an error**
573
547
 
574
548
 
575
- * **Then the "..." field should have no error**
576
-
577
-
578
- * **Then the "..." checkbox should( not)? be checked( and disabled)?**
549
+ * **Then the "..." checkbox should( not)? be checked?**
579
550
 
580
551
 
581
552
  * **Then the radio button "..." should( not)? be (checked|selected)**
@@ -628,14 +599,12 @@ deprecation notice. Decide for yourself whether you want to use them:
628
599
  * **When I reload the page**
629
600
 
630
601
 
631
- * **Then (the tag )?"..." should( not)? be visible**
602
+ * **Then (the tag )?"..." should be visible**
632
603
 
633
604
  Checks that an element is actually present and visible, also considering styles.
634
605
  Within a selenium test, the browser is asked whether the element is really visible
635
606
  In a non-selenium test, we only check for `.hidden`, `.invisible` or `style: display:none`
636
607
 
637
- The step 'Then (the tag )?"..." should **not** be visible' is ambiguous. Please use 'Then (the tag )?"..." should be hidden' or 'Then I should not see "..."' instead. Note that the **not** option will be removed in future versions of Spreewald.
638
-
639
608
  More details [here](https://makandracards.com/makandra/1049-capybara-check-that-a-page-element-is-hidden-via-css)
640
609
 
641
610
 
@@ -688,11 +657,6 @@ deprecation notice. Decide for yourself whether you want to use them:
688
657
  got: "http://makandra.com/" (using =~)
689
658
 
690
659
 
691
- * **Then I should get a text response**
692
-
693
- Checks that the result has content type `text/plain`
694
-
695
-
696
660
  * **When I follow "..." inside any "..."**
697
661
 
698
662
  Click a link within an element matching the given selector. Will try to be clever
@@ -728,13 +692,6 @@ deprecation notice. Decide for yourself whether you want to use them:
728
692
  Tests that a field with the given label is visible.
729
693
 
730
694
 
731
- * **When I wait for the page to load**
732
-
733
- Waits for the page to finish loading and AJAX requests to finish.
734
-
735
- More details [here](https://makandracards.com/makandra/12139-waiting-for-page-loads-and-ajax-requests-to-finish-with-capybara).
736
-
737
-
738
695
  * **When I perform basic authentication as ".../..." and go to ...**
739
696
 
740
697
  Performs HTTP basic authentication with the given credentials and visits the given path.
@@ -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 2."
243
+ Then the output should contain "Spreewald 3."
244
244
 
245
245
  When I run `spreewald -v`
246
- Then the output should contain "Spreewald 2."
246
+ Then the output should contain "Spreewald 3."
@@ -5,15 +5,8 @@ Then /^it should work(.+?)?$/ do |message|
5
5
  pending(message)
6
6
  end.overridable
7
7
 
8
- # nodoc
9
- Then 'debugger' do
10
- warn 'The step "Then debugger" will be removed in future versions of Spreewald. Please use "Then console" instead.'
11
- step 'console' # Alias
12
- end.overridable
13
-
14
8
  # Pauses test execution and opens an IRB shell with current context. Does not halt the application-
15
- # under-test. (Replaces the "Then debugger" step that has never been adequate
16
- # for its job)
9
+ # under-test.
17
10
  Then 'console' do
18
11
  require 'irb'
19
12
  ARGV.clear # IRB takes ARGV as its own arguments
@@ -17,51 +17,53 @@ end.overridable
17
17
  # From: max.mustermann@example.com
18
18
  # Reply-To: mmuster@gmail.com
19
19
  # To: john.doe@example.com
20
+ # CC: jane.doe@example.com
21
+ # BCC: johnny.doe@example.com
20
22
  # Subject: The subject may contain "quotes"
21
- # Attachments: ...
23
+ # Attachments: image.jpg, attachment.pdf
24
+ #
25
+ # This is the message body. You can use * as a wildcard to omit the rest
26
+ # of a line *
27
+ # Or you can omit multiple lines if the asterisk is the only
28
+ # character in a single line, like this:
29
+ # *
22
30
  #
23
- # Message body goes here.
24
31
  # """
25
32
  #
26
- # You may skip lines in the header, of course. Note that the mail body is only checked for
27
- # _inclusion_. That means you can only test a prefix of the body. The subject may also be
28
- # a prefix.
29
- Then /^(an|no) e?mail should have been sent with:$/ do |mode, raw_data|
33
+ # You may skip lines in the header, of course.
34
+ Then /^(an?|no)( HTML| plain-text|) e?mail should have been sent with:$/ do |mode, type, raw_data|
30
35
  patiently do
31
- raw_data.strip!
32
- header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
33
- conditions = {}
34
- header.split("\n").each do |row|
35
- if row.match(/^[a-z\-]+: /i)
36
- key, value = row.split(": ", 2)
37
- conditions[key.underscore.to_sym] = value
36
+ results = MailFinder.find(raw_data, type.strip)
37
+
38
+ if mode == 'no'
39
+ expect(results).to be_empty
40
+ else
41
+ if results.one?
42
+ @mail = results.mails[0]
43
+ elsif results.many?
44
+ warn <<-WARNING
45
+ #{results.size} emails were found with the following conditions.
46
+ You may want to make the description more precise or clear the emails in between.
47
+ #{raw_data}
48
+ WARNING
49
+ else
50
+ message = <<-ERROR
51
+ No matching mail was found. There were #{ActionMailer::Base.deliveries.size} mails in total.
52
+ #{results.matching_header.size} of those had matching headers.
53
+ ERROR
54
+ if results.matching_header.empty?
55
+ message << "Expected\n" + '-' * 80 + "\n"
56
+ message << raw_data.split(/\n\n/, 2)[0] # Show the expected header
57
+ message << "\n" + '-' * 80 + "\n\n"
58
+ message << MailFinder.show_mails(ActionMailer::Base.deliveries, true)
59
+ else
60
+ message << "\nTried to match #{results.body_regex.inspect} in the following mails:\n"
61
+ message << results.matching_header.map { |mail| MailFinder.email_text_body(mail, type.strip).strip.inspect }.join("\n")
62
+ message << "\n"
63
+ end
64
+ raise RSpec::Expectations::ExpectationNotMetError.new(message)
38
65
  end
39
66
  end
40
- conditions[:body] = body if body
41
- @mail = MailFinder.find(conditions)
42
- expectation = mode == 'no' ? 'not_to' : 'to'
43
- expect(@mail).send(expectation, be_present)
44
- end
45
- end.overridable
46
-
47
- # Example:
48
- #
49
- # Then an email should have been sent from "max.mustermann@example.com" to "john.doe@example.com" with bcc "john.wane@example.com" and with cc "foo@bar.com" and the subject "The subject" and the body "The body" and the attachments "attachment.pdf"
50
- #
51
- # You may skip parts, of course.
52
- Then /^(an|no) e?mail should have been sent((?: |and|with|from "[^"]+"|bcc "[^"]+"|cc "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/ do |mode, query|
53
- patiently do
54
- conditions = {}
55
- conditions[:to] = $1 if query =~ /to "([^"]+)"/
56
- conditions[:Cc] = $1 if query =~ /cc "([^"]+)"/
57
- conditions[:bcc] = $1 if query =~ /bcc "([^"]+)"/
58
- conditions[:from] = $1 if query =~ /from "([^"]+)"/
59
- conditions[:subject] = $1 if query =~ /the subject "([^"]+)"/
60
- conditions[:body] = $1 if query =~ /the body "([^"]+)"/
61
- conditions[:attachments] = $1 if query =~ /the attachments "([^"]+)"/
62
- @mail = MailFinder.find(conditions)
63
- expectation = mode == 'no' ? 'not_to' : 'to'
64
- expect(@mail).send(expectation, be_present)
65
67
  end
66
68
  end.overridable
67
69
 
@@ -88,45 +90,31 @@ Then /^no e?mail should have been sent$/ do
88
90
  end.overridable
89
91
 
90
92
  # Checks that the last sent email includes some text
91
- Then /^I should see "([^\"]*)" in the e?mail$/ do |text|
92
- expect(MailFinder.email_text_body(ActionMailer::Base.deliveries.last)).to include(text)
93
+ Then /^I should see "([^\"]*)" in the( HTML| plain-text|) e?mail$/ do |text, type|
94
+ expect(MailFinder.email_text_body(ActionMailer::Base.deliveries.last, type.strip)).to include(text)
93
95
  end.overridable
94
96
 
95
- # Print all sent emails to STDOUT.
96
- Then /^show me the e?mails$/ do
97
- ActionMailer::Base.deliveries.each_with_index do |mail, i|
98
- puts "E-Mail ##{i}"
99
- print "-" * 80
100
- puts [ "From: #{mail.from}",
101
- "To: #{mail.to}",
102
- "Subject: #{mail.subject}",
103
- "\n" + MailFinder.email_text_body(mail)
104
- ].join("\n")
105
- print "-" * 80
97
+ # Print all sent emails to STDOUT (optionally only the headers).
98
+ Then /^show me the e?mail( header)?s$/ do |only_header|
99
+ if ActionMailer::Base.deliveries.empty?
100
+ puts MailFinder.show_mails(ActionMailer::Base.deliveries, only_header)
101
+ else
102
+ puts "No emails found" if ActionMailer::Base.deliveries.empty?
106
103
  end
107
- end.overridable
108
104
 
109
- # Example:
110
- #
111
- # And that mail should have the following lines in the body:
112
- # """
113
- # All of these lines
114
- # need to be present
115
- # """
116
- #
117
- # You may skip lines, of course. Note that you may also omit text at the end of each line.
118
- Then /^that e?mail should( not)? have the following lines in the body:$/ do |negate, body|
119
- expectation = negate ? 'not_to' : 'to'
120
- mail = @mail || ActionMailer::Base.deliveries.last
121
- email_text_body = MailFinder.email_text_body(mail)
105
+ end.overridable
122
106
 
123
- body.to_s.strip.split(/\n/).each do |line|
124
- expect(email_text_body).send(expectation, include(line.strip))
107
+ # Print a subset of all sent emails to STDOUT
108
+ # This uses the same syntax as `Then an email should have been sent with:`
109
+ Then /^show me the e?mail( header)?s with:$/ do |only_header, raw_data|
110
+ results = MailFinder.find(raw_data)
111
+ if results.empty?
112
+ if results.matching_header.empty?
113
+ puts "There are no emails matching the given header."
114
+ else
115
+ puts "There are no emails matching the given header and body, but #{results.matching_header.size} matching only the header."
116
+ end
125
117
  end
126
- end.overridable
127
118
 
128
- # Checks that the text should be included anywhere in the retrieved email body
129
- Then /^that e?mail should have the following (?:|content in the )body:$/ do |body|
130
- mail = @mail || ActionMailer::Base.deliveries.last
131
- expect(MailFinder.email_text_body(mail)).to include(body.strip)
119
+ print MailFinder.show_mails(results.mails, only_header)
132
120
  end.overridable
@@ -201,10 +201,10 @@ Then /^I should( not)? see a field "([^"]*)"$/ do |negate, name|
201
201
  expectation = negate ? :not_to : :to
202
202
  patiently do
203
203
  begin
204
- # In old Capybaras find_field returns nil, so we assign it to `field`
205
- field = find_field(name)
204
+ # In old Capybaras find returns nil, so we assign it to `field`
205
+ field = find_with_disabled(:field, name)
206
206
  rescue Capybara::ElementNotFound
207
- # In Capybara 0.4+ #find_field raises an error instead of returning nil
207
+ # In Capybara 0.4+ #find raises an error instead of returning nil
208
208
  # We must explicitely reset the field variable from a previous patiently iteration
209
209
  field = nil
210
210
  end
@@ -327,7 +327,7 @@ end.overridable
327
327
  # Checks that an input field contains some value (allowing * as wildcard character)
328
328
  Then /^the "([^"]*)" field should (not )?contain "([^"]*)"$/ do |label, negate, expected_string|
329
329
  patiently do
330
- field = find_field(label)
330
+ field = find_with_disabled(:field, label)
331
331
  field_value = case field.tag_name
332
332
  when 'select'
333
333
  options = field.all('option')
@@ -347,7 +347,7 @@ end.overridable
347
347
  # Checks that a multiline textarea contains some value (allowing * as wildcard character)
348
348
  Then(/^the "(.*?)" field should (not )?contain:$/) do |label, negate, expected_string|
349
349
  patiently do
350
- field = find_field(label)
350
+ field = find_with_disabled(:field, label)
351
351
  expect(field.value.chomp).send(negate ? :not_to : :to, contain_with_wildcards(expected_string))
352
352
  end
353
353
  end.overridable
@@ -369,7 +369,7 @@ end.overridable
369
369
  # Checks that an input field was wrapped with a validation error
370
370
  Then /^the "([^"]*)" field should have the error "([^"]*)"$/ do |field, error_message|
371
371
  patiently do
372
- element = find_field(field)
372
+ element = find_with_disabled(:field, field)
373
373
  classes = element.find(:xpath, '..')[:class].split(' ')
374
374
 
375
375
  form_for_input = element.find(:xpath, 'ancestor::form[1]')
@@ -390,30 +390,17 @@ end.overridable
390
390
  Then /^the "([^\"]*)" field should( not)? have an error$/ do |label, negate|
391
391
  patiently do
392
392
  expectation = negate ? :not_to : :to
393
- field = find_field(label)
393
+ field = find_with_disabled(:field, label)
394
394
  expect(field[:id]).to be_present # prevent bad CSS selector if field lacks id
395
395
  expect(page).send(expectation, have_css(".field_with_errors ##{field[:id]}"))
396
396
  end
397
397
  end.overridable
398
398
 
399
- Then /^the "([^"]*)" field should have no error$/ do |field|
400
- patiently do
401
- element = find_field(field)
402
- classes = element.find(:xpath, '..')[:class].split(' ')
403
- expect(classes).not_to include('field_with_errors')
404
- expect(classes).not_to include('error')
405
- end
406
- end.overridable
407
-
408
- Then /^the "([^"]*)" checkbox should( not)? be checked( and disabled)?$/ do |label, negate, disabled|
399
+ Then /^the "([^"]*)" checkbox should( not)? be checked?$/ do |label, negate|
409
400
  expectation = negate ? :not_to : :to
410
401
 
411
402
  patiently do
412
- field = if Spreewald::Comparison.compare_versions(Capybara::VERSION, :<, "2.1")
413
- find_field(label)
414
- else
415
- find_field(label, :disabled => !!disabled)
416
- end
403
+ field = find_with_disabled(:field, label)
417
404
  expect(field).send expectation, be_checked
418
405
  end
419
406
  end.overridable
@@ -484,7 +471,7 @@ end.overridable
484
471
 
485
472
  Then /^nothing should be selected for "([^"]*)"$/ do |field|
486
473
  patiently do
487
- select = find_field(field)
474
+ select = find_with_disabled(:field, field)
488
475
  begin
489
476
  selected_option = select.find(:xpath, ".//option[@selected = 'selected']") || select.all(:css, 'option').first
490
477
  value = selected_option ? selected_option.value : nil
@@ -504,11 +491,11 @@ Then /^"([^"]*)" should( not)? be an option for "([^"]*)"$/ do |value, negate, f
504
491
  patiently do
505
492
  if negate
506
493
  begin
507
- expect(find_field(field)).to have_no_css(*finder_arguments)
494
+ expect(find_with_disabled(:field, field)).to have_no_css(*finder_arguments)
508
495
  rescue Capybara::ElementNotFound
509
496
  end
510
497
  else
511
- expect(find_field(field)).to have_css(*finder_arguments)
498
+ expect(find_with_disabled(:field, field)).to have_css(*finder_arguments)
512
499
  end
513
500
  end
514
501
  end.overridable
@@ -537,18 +524,12 @@ end.overridable
537
524
  # Within a selenium test, the browser is asked whether the element is really visible
538
525
  # In a non-selenium test, we only check for `.hidden`, `.invisible` or `style: display:none`
539
526
  #
540
- # The step 'Then (the tag )?"..." should **not** be visible' is ambiguous. Please use 'Then (the tag )?"..." should be hidden' or 'Then I should not see "..."' instead. Note that the **not** option will be removed in future versions of Spreewald.
541
- #
542
527
  # More details [here](https://makandracards.com/makandra/1049-capybara-check-that-a-page-element-is-hidden-via-css)
543
- Then /^(the tag )?"([^\"]+)" should( not)? be visible$/ do |tag, selector_or_text, hidden|
544
- if hidden
545
- warn "The step 'Then ... should not be visible' is prone to misunderstandings. Please use 'Then ... should be hidden' or 'Then I should not see ...' instead."
546
- end
547
-
528
+ Then /^(the tag )?"([^\"]+)" should be visible$/ do |tag, selector_or_text|
548
529
  options = {}
549
530
  tag ? options.store(:selector, selector_or_text) : options.store(:text, selector_or_text)
550
531
 
551
- hidden ? assert_hidden(options) : assert_visible(options)
532
+ assert_visible(options)
552
533
  end.overridable
553
534
 
554
535
  # Checks that an element is actually present and hidden, also considering styles.
@@ -616,11 +597,6 @@ Then /^"([^"]*)" should link to "([^"]*)"$/ do |link_label, target|
616
597
  end
617
598
  end.overridable
618
599
 
619
- # Checks that the result has content type `text/plain`
620
- Then /^I should get a text response$/ do
621
- step 'I should get a response with content-type "text/plain"'
622
- end.overridable
623
-
624
600
  # Click a link within an element matching the given selector. Will try to be clever
625
601
  # and disregard elements that don't contain a matching link.
626
602
  #
@@ -689,11 +665,11 @@ end.overridable
689
665
  # Tests that a field with the given label is visible.
690
666
  Then /^the "([^\"]*)" field should( not)? be visible$/ do |label, hidden|
691
667
  if Spreewald::Comparison.compare_versions(Capybara::VERSION, :<, "2.1")
692
- field = find_field(label)
668
+ field = find_with_disabled(:field, label)
693
669
  else
694
670
  # Capybara 2.1+ won't usually interact with hidden elements,
695
671
  # but we can override this behavior by passing { visible: false }
696
- field = find_field(label, :visible => false)
672
+ field = find_with_disabled(:field, label, :visible => false)
697
673
  end
698
674
 
699
675
  selector = "##{field['id']}"
@@ -705,19 +681,6 @@ Then /^the "([^\"]*)" field should( not)? be visible$/ do |label, hidden|
705
681
  end
706
682
  end.overridable
707
683
 
708
- # Waits for the page to finish loading and AJAX requests to finish.
709
- #
710
- # More details [here](https://makandracards.com/makandra/12139-waiting-for-page-loads-and-ajax-requests-to-finish-with-capybara).
711
- When /^I wait for the page to load$/ do
712
- if javascript_capable?
713
- patiently do
714
- # when no jQuery is loaded, we assume there are no pending AJAX requests
715
- page.execute_script("return typeof jQuery === 'undefined' || $.active == 0;").should == true
716
- end
717
- end
718
- page.has_content? ''
719
- end.overridable
720
-
721
684
  # Performs HTTP basic authentication with the given credentials and visits the given path.
722
685
  #
723
686
  # More details [here](https://makandracards.com/makandra/971-perform-http-basic-authentication-in-cucumber).
@@ -754,7 +717,7 @@ end.overridable
754
717
  # Tests whether a select field is sorted. Uses Array#natural_sort, if defined;
755
718
  # Array#sort else.
756
719
  Then /^the "(.*?)" select should( not)? be sorted$/ do |label, negate|
757
- select = find_field(label)
720
+ select = find_with_disabled(:field, label)
758
721
  options = select.all('option').reject { |o| o.value.blank? }
759
722
  option_texts = options.collect(&:text)
760
723