spreewald 2.1.3 → 2.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 156277b1ff11d278f195b09266237155fa477f7811ed585d3e766431fd1b4e20
4
- data.tar.gz: 03573bd49630806f3bbec0f2d073438ed419e81a60c4cc4b3bccc96f26f42439
2
+ SHA1:
3
+ metadata.gz: c6344c3e67a52d140623e262f62163db7c50d4c8
4
+ data.tar.gz: 615431258c8bacd8e28459adf8726987226cb348
5
5
  SHA512:
6
- metadata.gz: 1beb236444cf36b9af9a434f40fd8d28d656daf4eb5e2fa6e7b9dba91ea170e0df8e35d1e9b72b4d0795f9adedd6817090e6f8652810c72e3a660cf295375f62
7
- data.tar.gz: bea5a66a9f2bed6098309e974fa7d5f381383885835b47e047d0454e46a1f87357e25df578e40fe70d65aa1fd115a482fa1026b2a7a59fd0342f077222b4303b
6
+ metadata.gz: d831672bf55cb2b5cdc5fb239dfbc1ac494092e00dc518d8d868513f615416d84dd96b2ea49ac7f1fd9c0f5792c402c9ee36812bdb74aaf25532b5870405ba2b
7
+ data.tar.gz: dd374015482e0fa3403e4d18ee4885635db1d6295e7f2f2c2626bac6acc4804d0c9cbdce6a41a0d56b08bd4046f13032173dce5b49a6de9cb34c38cc61c22ebb
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
+ ## 2.2.0
7
+ - Add a new step `I should( not)? see a link labeled "STRING"`.
8
+ - Refer to Capybara 3's new flag `Capybara.default_normalize_ws = true` in the READNE,
9
+
6
10
  ## 2.1.3
7
11
  The `I should(not )? see /REGEXP/` step no longer refuses slashes as part of the regular expression. You can thus match full domains and more.
8
12
 
data/README.md CHANGED
@@ -83,6 +83,17 @@ More info [here](https://makandracards.com/makandra/12139-waiting-for-page-load-
83
83
  Thanks to [cucumber_priority](https://github.com/makandra/cucumber_priority) you can override any step definition from Spreewald with your own pattern. Cucumber will not raise `Cucumber::Ambiguous` if your custom steps collide with a Spreewald step.
84
84
 
85
85
 
86
+ ## A note on Capybara 3
87
+
88
+ If you are upgrading from Capybara 2 to Capybara 3, you might [see failing tests](https://github.com/makandra/spreewald/issues/95) with Spreewald steps like `I should see`. This is caused by a breaking change in [Capybara's Finders](https://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Finders) that accept a `:text` option. To activate Capybara 2 behavior globally in your project, enable this flag:
89
+
90
+ ```ruby
91
+ Capybara.default_normalize_ws = true
92
+ ````
93
+
94
+ This will affect all Spreewald steps that are using Capybara's `:text` option.
95
+
96
+
86
97
  ## Contributing
87
98
 
88
99
  ### Testing
@@ -390,6 +401,81 @@ deprecation notice. Decide for yourself whether you want to use them:
390
401
  * **Then I should not see /.../**
391
402
 
392
403
 
404
+ * **Then I should( not)? see a field "..."**
405
+
406
+ Checks for the existance of an input field (given its id or label)
407
+
408
+
409
+ * **Then I should( not)? see the (number|amount) ([\-\d,\.]+)( ...)?**
410
+
411
+ Use this step to test for a number or money amount instead of a simple `Then I should see`
412
+
413
+ Checks for an unexpected minus sign, correct decimal places etc.
414
+
415
+ See [here](https://makandracards.com/makandra/1225-test-that-a-number-or-money-amount-is-shown-with-cucumber) for details
416
+
417
+
418
+ * **Then I should see '...'**
419
+
420
+ Like `Then I should see`, but with single instead of double quotes. In case
421
+ the expected string contains quotes as well.
422
+
423
+
424
+ * **Then I should see "..." in the HTML**
425
+
426
+ Check that the raw HTML contains a string
427
+
428
+
429
+ * **Then I should not see "..." in the HTML**
430
+
431
+
432
+ * **Then I should see an error**
433
+
434
+ Checks that status code is 400..599
435
+
436
+
437
+ * **Then I should (not )?see (an|the) element "..."**
438
+
439
+ Check that an element with the given selector is present on the page.
440
+
441
+ Example:
442
+
443
+ Then I should see an element ".panel"
444
+ Then I should see the element ".panel"
445
+ Then I should not see an element ".sidebar"
446
+ Then I should not see the element ".sidebar"
447
+
448
+
449
+ * **Then I should (not )?see (an|the) element for ...**
450
+
451
+ Check that an element with the given [selector alias](https://github.com/makandra/spreewald/blob/master/examples/selectors.rb) is present on the page.
452
+
453
+ Example:
454
+
455
+ Then I should see an element for the panel
456
+ Then I should see the element for the panel
457
+ Then I should not see an element for the sidebar
458
+ Then I should not see the element for the sidebar
459
+
460
+
461
+ * **Then I should see in this order:?**
462
+
463
+ Checks that these strings are rendered in the given order in a single line or in multiple lines
464
+
465
+ Example:
466
+
467
+ Then I should see in this order:
468
+ | Alpha Group |
469
+ | Augsburg |
470
+ | Berlin |
471
+ | Beta Group |
472
+
473
+
474
+ * **Then I should( not)? see a link labeled "..."**
475
+
476
+ Checks that the page contains a link with a given text or title attribute.
477
+
478
+
393
479
  * **Then the "..." field should (not )?contain "..."**
394
480
 
395
481
  Checks that an input field contains some value (allowing * as wildcard character)
@@ -444,20 +530,6 @@ deprecation notice. Decide for yourself whether you want to use them:
444
530
  Open the current Capybara page using the `launchy` or `capybara_screenshot` gem
445
531
 
446
532
 
447
- * **Then I should( not)? see a field "..."**
448
-
449
- Checks for the existance of an input field (given its id or label)
450
-
451
-
452
- * **Then I should( not)? see the (number|amount) ([\-\d,\.]+)( ...)?**
453
-
454
- Use this step to test for a number or money amount instead of a simple `Then I should see`
455
-
456
- Checks for an unexpected minus sign, correct decimal places etc.
457
-
458
- See [here](https://makandracards.com/makandra/1225-test-that-a-number-or-money-amount-is-shown-with-cucumber) for details
459
-
460
-
461
533
  * **Then I should get a response with content-type "..."**
462
534
 
463
535
  Checks `Content-Type` HTTP header
@@ -483,25 +555,6 @@ deprecation notice. Decide for yourself whether you want to use them:
483
555
  Checks for the presence of an option in a select
484
556
 
485
557
 
486
- * **Then I should see '...'**
487
-
488
- Like `Then I should see`, but with single instead of double quotes. In case
489
- the expected string contains quotes as well.
490
-
491
-
492
- * **Then I should see "..." in the HTML**
493
-
494
- Check that the raw HTML contains a string
495
-
496
-
497
- * **Then I should not see "..." in the HTML**
498
-
499
-
500
- * **Then I should see an error**
501
-
502
- Checks that status code is 400..599
503
-
504
-
505
558
  * **Then the window should be titled "..."**
506
559
 
507
560
 
@@ -568,30 +621,6 @@ deprecation notice. Decide for yourself whether you want to use them:
568
621
  got: "http://makandra.com/" (using =~)
569
622
 
570
623
 
571
- * **Then I should (not )?see (an|the) element "..."**
572
-
573
- Check that an element with the given selector is present on the page.
574
-
575
- Example:
576
-
577
- Then I should see an element ".panel"
578
- Then I should see the element ".panel"
579
- Then I should not see an element ".sidebar"
580
- Then I should not see the element ".sidebar"
581
-
582
-
583
- * **Then I should (not )?see (an|the) element for ...**
584
-
585
- Check that an element with the given [selector alias](https://github.com/makandra/spreewald/blob/master/examples/selectors.rb) is present on the page.
586
-
587
- Example:
588
-
589
- Then I should see an element for the panel
590
- Then I should see the element for the panel
591
- Then I should not see an element for the sidebar
592
- Then I should not see the element for the sidebar
593
-
594
-
595
624
  * **Then I should get a text response**
596
625
 
597
626
  Checks that the result has content type `text/plain`
@@ -625,19 +654,6 @@ deprecation notice. Decide for yourself whether you want to use them:
625
654
  * **When I switch to the new tab**
626
655
 
627
656
 
628
- * **Then I should see in this order:?**
629
-
630
- Checks that these strings are rendered in the given order in a single line or in multiple lines
631
-
632
- Example:
633
-
634
- Then I should see in this order:
635
- | Alpha Group |
636
- | Augsburg |
637
- | Berlin |
638
- | Beta Group |
639
-
640
-
641
657
  * **Then the "..." (field|button|checkbox) should( not)? be disabled**
642
658
 
643
659
  Tests that an input or button with the given label is disabled.
@@ -195,6 +195,123 @@ Then /^(?:|I )should not see \/(.*)\/$/ do |regexp|
195
195
  end
196
196
  end.overridable
197
197
 
198
+ # Checks for the existance of an input field (given its id or label)
199
+ Then /^I should( not)? see a field "([^"]*)"$/ do |negate, name|
200
+ expectation = negate ? :not_to : :to
201
+ patiently do
202
+ begin
203
+ # In old Capybaras find_field returns nil, so we assign it to `field`
204
+ field = find_field(name)
205
+ rescue Capybara::ElementNotFound
206
+ # In Capybara 0.4+ #find_field raises an error instead of returning nil
207
+ # We must explicitely reset the field variable from a previous patiently iteration
208
+ field = nil
209
+ end
210
+ expect(field).send(expectation, be_present)
211
+ end
212
+ end.overridable
213
+
214
+ # Use this step to test for a number or money amount instead of a simple `Then I should see`
215
+ #
216
+ # Checks for an unexpected minus sign, correct decimal places etc.
217
+ #
218
+ # See [here](https://makandracards.com/makandra/1225-test-that-a-number-or-money-amount-is-shown-with-cucumber) for details
219
+ Then /^I should( not)? see the (?:number|amount) ([\-\d,\.]+)(?: (.*?))?$/ do |negate, amount, unit|
220
+ no_minus = amount.starts_with?('-') ? '' : '[^\\-]'
221
+ nbsp = " "
222
+ regexp = Regexp.new(no_minus + "\\b" + Regexp.quote(amount) + (unit ? "( |#{nbsp}| )(#{unit}|#{Regexp.quote(HTMLEntities.new.encode(unit, :named))})" :"\\b"))
223
+ expectation = negate ? :not_to : :to
224
+ patiently do
225
+ expect(page.body).send(expectation, match(regexp))
226
+ end
227
+ end.overridable
228
+
229
+ # Like `Then I should see`, but with single instead of double quotes. In case
230
+ # the expected string contains quotes as well.
231
+ Then /^(?:|I )should see '([^']*)'$/ do |text|
232
+ patiently do
233
+ expect(page).to have_content(text)
234
+ end
235
+ end.overridable
236
+
237
+ # Check that the raw HTML contains a string
238
+ Then /^I should see "([^\"]*)" in the HTML$/ do |text|
239
+ patiently do
240
+ expect(page.body).to include(text)
241
+ end
242
+ end.overridable
243
+
244
+ Then /^I should not see "([^\"]*)" in the HTML$/ do |text|
245
+ patiently do
246
+ expect(page.body).not_to include(text)
247
+ end
248
+ end.overridable
249
+
250
+ # Checks that status code is 400..599
251
+ Then /^I should see an error$/ do
252
+ expect((400 .. 599)).to include(page.status_code)
253
+ end.overridable
254
+
255
+ # Check that an element with the given selector is present on the page.
256
+ #
257
+ # Example:
258
+ #
259
+ # Then I should see an element ".panel"
260
+ # Then I should see the element ".panel"
261
+ # Then I should not see an element ".sidebar"
262
+ # Then I should not see the element ".sidebar"
263
+ Then /^I should (not )?see (?:an|the) element "([^"]+)"$/ do |negate, selector|
264
+ expectation = negate ? :not_to : :to
265
+ patiently do
266
+ expect(page).send(expectation, have_css(selector))
267
+ end
268
+ end.overridable
269
+
270
+ # Check that an element with the given [selector alias](https://github.com/makandra/spreewald/blob/master/examples/selectors.rb) is present on the page.
271
+ #
272
+ # Example:
273
+ #
274
+ # Then I should see an element for the panel
275
+ # Then I should see the element for the panel
276
+ # Then I should not see an element for the sidebar
277
+ # Then I should not see the element for the sidebar
278
+ Then /^I should (not )?see (?:an|the) element for (.*?)$/ do |negate, locator|
279
+ expectation = negate ? :not_to : :to
280
+ selector = _selector_for(locator)
281
+ patiently do
282
+ expect(page).send(expectation, have_selector(*selector))
283
+ end
284
+ end.overridable(:priority => -5) # priority must be lower than the "within" step
285
+
286
+ # Checks that these strings are rendered in the given order in a single line or in multiple lines
287
+ #
288
+ # Example:
289
+ #
290
+ # Then I should see in this order:
291
+ # | Alpha Group |
292
+ # | Augsburg |
293
+ # | Berlin |
294
+ # | Beta Group |
295
+ Then /^I should see in this order:?$/ do |text|
296
+ if text.is_a?(String)
297
+ lines = text.split(/\n/)
298
+ else
299
+ lines = text.raw.flatten
300
+ end
301
+ lines = lines.collect { |line| line.gsub(/\s+/, ' ')}.collect(&:strip).reject(&:blank?)
302
+ pattern = lines.collect(&Regexp.method(:quote)).join('.*?')
303
+ pattern = Regexp.compile(pattern)
304
+ patiently do
305
+ expect(page.text.gsub(/\s+/, ' ')).to match(pattern)
306
+ end
307
+ end.overridable
308
+
309
+ # Checks that the page contains a link with a given text or title attribute.
310
+ Then /^I should( not)? see a link labeled "([^"]*)"$/ do |negate, label|
311
+ expectation = negate ? :not_to : :to
312
+ link = page.first('a', :text => label, minimum: 0) || page.first(%(a[title="#{label}"]), minimum: 0)
313
+ expect(link).send(expectation, be_present)
314
+ end
198
315
 
199
316
  # Checks that an input field contains some value (allowing * as wildcard character)
200
317
  Then /^the "([^"]*)" field should (not )?contain "([^"]*)"$/ do |label, negate, expected_string|
@@ -326,38 +443,6 @@ Then /^show me the page$/ do
326
443
  end.overridable
327
444
 
328
445
 
329
- # Checks for the existance of an input field (given its id or label)
330
- Then /^I should( not)? see a field "([^"]*)"$/ do |negate, name|
331
- expectation = negate ? :not_to : :to
332
- patiently do
333
- begin
334
- # In old Capybaras find_field returns nil, so we assign it to `field`
335
- field = find_field(name)
336
- rescue Capybara::ElementNotFound
337
- # In Capybara 0.4+ #find_field raises an error instead of returning nil
338
- # We must explicitely reset the field variable from a previous patiently iteration
339
- field = nil
340
- end
341
- expect(field).send(expectation, be_present)
342
- end
343
- end.overridable
344
-
345
-
346
- # Use this step to test for a number or money amount instead of a simple `Then I should see`
347
- #
348
- # Checks for an unexpected minus sign, correct decimal places etc.
349
- #
350
- # See [here](https://makandracards.com/makandra/1225-test-that-a-number-or-money-amount-is-shown-with-cucumber) for details
351
- Then /^I should( not)? see the (?:number|amount) ([\-\d,\.]+)(?: (.*?))?$/ do |negate, amount, unit|
352
- no_minus = amount.starts_with?('-') ? '' : '[^\\-]'
353
- nbsp = " "
354
- regexp = Regexp.new(no_minus + "\\b" + Regexp.quote(amount) + (unit ? "( |#{nbsp}| )(#{unit}|#{Regexp.quote(HTMLEntities.new.encode(unit, :named))})" :"\\b"))
355
- expectation = negate ? :not_to : :to
356
- patiently do
357
- expect(page.body).send(expectation, match(regexp))
358
- end
359
- end.overridable
360
-
361
446
  # Checks `Content-Type` HTTP header
362
447
  Then /^I should get a response with content-type "([^\"]*)"$/ do |expected_content_type|
363
448
  expect(page.response_headers['Content-Type']).to match /\A#{Regexp.quote(expected_content_type)}($|;)/
@@ -406,32 +491,6 @@ Then /^"([^"]*)" should( not)? be an option for "([^"]*)"$/ do |value, negate, f
406
491
  end
407
492
  end.overridable
408
493
 
409
- # Like `Then I should see`, but with single instead of double quotes. In case
410
- # the expected string contains quotes as well.
411
- Then /^(?:|I )should see '([^']*)'$/ do |text|
412
- patiently do
413
- expect(page).to have_content(text)
414
- end
415
- end.overridable
416
-
417
- # Check that the raw HTML contains a string
418
- Then /^I should see "([^\"]*)" in the HTML$/ do |text|
419
- patiently do
420
- expect(page.body).to include(text)
421
- end
422
- end.overridable
423
-
424
- Then /^I should not see "([^\"]*)" in the HTML$/ do |text|
425
- patiently do
426
- expect(page.body).not_to include(text)
427
- end
428
- end.overridable
429
-
430
- # Checks that status code is 400..599
431
- Then /^I should see an error$/ do
432
- expect((400 .. 599)).to include(page.status_code)
433
- end.overridable
434
-
435
494
  Then /^the window should be titled "([^"]*)"$/ do |title|
436
495
  patiently do
437
496
  expect(pag).to have_css('title', :text => title)
@@ -531,38 +590,6 @@ Then /^"([^"]*)" should link to "([^"]*)"$/ do |link_label, target|
531
590
  end
532
591
  end.overridable
533
592
 
534
- # Check that an element with the given selector is present on the page.
535
- #
536
- # Example:
537
- #
538
- # Then I should see an element ".panel"
539
- # Then I should see the element ".panel"
540
- # Then I should not see an element ".sidebar"
541
- # Then I should not see the element ".sidebar"
542
- Then /^I should (not )?see (?:an|the) element "([^"]+)"$/ do |negate, selector|
543
- expectation = negate ? :not_to : :to
544
- patiently do
545
- expect(page).send(expectation, have_css(selector))
546
- end
547
- end.overridable
548
-
549
- # Check that an element with the given [selector alias](https://github.com/makandra/spreewald/blob/master/examples/selectors.rb) is present on the page.
550
- #
551
- # Example:
552
- #
553
- # Then I should see an element for the panel
554
- # Then I should see the element for the panel
555
- # Then I should not see an element for the sidebar
556
- # Then I should not see the element for the sidebar
557
- Then /^I should (not )?see (?:an|the) element for (.*?)$/ do |negate, locator|
558
- expectation = negate ? :not_to : :to
559
- selector = _selector_for(locator)
560
- patiently do
561
- expect(page).send(expectation, have_selector(*selector))
562
- end
563
- end.overridable(:priority => -5) # priority must be lower than the "within" step
564
-
565
-
566
593
  # Checks that the result has content type `text/plain`
567
594
  Then /^I should get a text response$/ do
568
595
  step 'I should get a response with content-type "text/plain"'
@@ -625,29 +652,6 @@ When /^I switch to the new tab$/ do
625
652
  end
626
653
  end.overridable
627
654
 
628
- # Checks that these strings are rendered in the given order in a single line or in multiple lines
629
- #
630
- # Example:
631
- #
632
- # Then I should see in this order:
633
- # | Alpha Group |
634
- # | Augsburg |
635
- # | Berlin |
636
- # | Beta Group |
637
- Then /^I should see in this order:?$/ do |text|
638
- if text.is_a?(String)
639
- lines = text.split(/\n/)
640
- else
641
- lines = text.raw.flatten
642
- end
643
- lines = lines.collect { |line| line.gsub(/\s+/, ' ')}.collect(&:strip).reject(&:blank?)
644
- pattern = lines.collect(&Regexp.method(:quote)).join('.*?')
645
- pattern = Regexp.compile(pattern)
646
- patiently do
647
- expect(page.text.gsub(/\s+/, ' ')).to match(pattern)
648
- end
649
- end.overridable
650
-
651
655
  # Tests that an input or button with the given label is disabled.
652
656
  Then /^the "([^\"]*)" (field|button|checkbox) should( not)? be disabled$/ do |label, kind, negate|
653
657
  if kind == 'field' || kind == 'checkbox'
@@ -1,3 +1,3 @@
1
1
  module Spreewald
2
- VERSION = '2.1.3'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (2.1.3)
4
+ spreewald (2.2.0)
5
5
  cucumber
6
6
  cucumber_priority (>= 0.3.0)
7
7
  rspec (>= 2.13.0)
@@ -0,0 +1,5 @@
1
+ .nested-link
2
+ %a First visible link
3
+ %a(title="Also matches via the title attribute") Second visible link
4
+
5
+ .unrelated-element
@@ -244,3 +244,12 @@ Feature: Web steps
244
244
  Scenario: /^I should get a download with filename "([^\"]*)"$/
245
245
  When I go to "/downloads/spreadsheet"
246
246
  Then I should get a download with filename "test.ods"
247
+
248
+
249
+ Scenario: /^I should( not)? see a link labeled "([^"]*)"$/
250
+ When I am on "/static_pages/links"
251
+ Then I should see a link labeled "First visible link"
252
+ And I should see a link labeled "First visible link" within ".nested-link"
253
+ And I should see a link labeled "Also matches via the title attribute"
254
+ But I should not see a link labeled "Nonexistent Link"
255
+ And I should not see a link labeled "First visible link" within ".unrelated-element"
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: 2.1.3
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -283,6 +283,7 @@ files:
283
283
  - tests/shared/app/views/static_pages/click_on.html.haml
284
284
  - tests/shared/app/views/static_pages/home.html.haml
285
285
  - tests/shared/app/views/static_pages/link_to_home.html.haml
286
+ - tests/shared/app/views/static_pages/links.html.haml
286
287
  - tests/shared/app/views/static_pages/overridden.html.haml
287
288
  - tests/shared/app/views/static_pages/see_element.html.haml
288
289
  - tests/shared/app/views/static_pages/visibility.html.haml
@@ -326,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
327
  version: '0'
327
328
  requirements: []
328
329
  rubyforge_project:
329
- rubygems_version: 2.7.6
330
+ rubygems_version: 2.6.14.3
330
331
  signing_key:
331
332
  specification_version: 4
332
333
  summary: Collection of useful cucumber steps.
@@ -437,6 +438,7 @@ test_files:
437
438
  - tests/shared/app/views/static_pages/click_on.html.haml
438
439
  - tests/shared/app/views/static_pages/home.html.haml
439
440
  - tests/shared/app/views/static_pages/link_to_home.html.haml
441
+ - tests/shared/app/views/static_pages/links.html.haml
440
442
  - tests/shared/app/views/static_pages/overridden.html.haml
441
443
  - tests/shared/app/views/static_pages/see_element.html.haml
442
444
  - tests/shared/app/views/static_pages/visibility.html.haml