capybara 3.29.0 → 3.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +19 -1
  3. data/README.md +1 -1
  4. data/lib/capybara/config.rb +7 -3
  5. data/lib/capybara/helpers.rb +3 -1
  6. data/lib/capybara/node/actions.rb +23 -19
  7. data/lib/capybara/node/document.rb +2 -2
  8. data/lib/capybara/node/document_matchers.rb +3 -3
  9. data/lib/capybara/node/element.rb +10 -8
  10. data/lib/capybara/node/finders.rb +12 -10
  11. data/lib/capybara/node/matchers.rb +39 -33
  12. data/lib/capybara/node/simple.rb +3 -1
  13. data/lib/capybara/queries/ancestor_query.rb +1 -1
  14. data/lib/capybara/queries/selector_query.rb +17 -4
  15. data/lib/capybara/queries/sibling_query.rb +1 -1
  16. data/lib/capybara/rack_test/browser.rb +4 -1
  17. data/lib/capybara/rack_test/driver.rb +1 -1
  18. data/lib/capybara/rack_test/form.rb +1 -1
  19. data/lib/capybara/selector.rb +22 -16
  20. data/lib/capybara/selector/css.rb +1 -1
  21. data/lib/capybara/selector/definition.rb +2 -2
  22. data/lib/capybara/selector/definition/button.rb +7 -2
  23. data/lib/capybara/selector/definition/checkbox.rb +2 -2
  24. data/lib/capybara/selector/definition/css.rb +3 -1
  25. data/lib/capybara/selector/definition/datalist_input.rb +1 -1
  26. data/lib/capybara/selector/definition/datalist_option.rb +1 -1
  27. data/lib/capybara/selector/definition/element.rb +1 -1
  28. data/lib/capybara/selector/definition/field.rb +1 -1
  29. data/lib/capybara/selector/definition/file_field.rb +1 -1
  30. data/lib/capybara/selector/definition/fillable_field.rb +1 -1
  31. data/lib/capybara/selector/definition/label.rb +3 -1
  32. data/lib/capybara/selector/definition/radio_button.rb +2 -2
  33. data/lib/capybara/selector/definition/select.rb +1 -1
  34. data/lib/capybara/selector/definition/table.rb +5 -2
  35. data/lib/capybara/selector/filter_set.rb +11 -9
  36. data/lib/capybara/selector/filters/base.rb +6 -1
  37. data/lib/capybara/selector/filters/locator_filter.rb +1 -1
  38. data/lib/capybara/selector/selector.rb +4 -2
  39. data/lib/capybara/selenium/driver.rb +19 -11
  40. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
  41. data/lib/capybara/selenium/extensions/html5_drag.rb +6 -5
  42. data/lib/capybara/selenium/node.rb +6 -4
  43. data/lib/capybara/selenium/nodes/chrome_node.rb +7 -3
  44. data/lib/capybara/selenium/nodes/edge_node.rb +3 -1
  45. data/lib/capybara/selenium/nodes/firefox_node.rb +1 -1
  46. data/lib/capybara/server.rb +15 -3
  47. data/lib/capybara/server/checker.rb +1 -1
  48. data/lib/capybara/server/middleware.rb +20 -10
  49. data/lib/capybara/session.rb +10 -8
  50. data/lib/capybara/session/config.rb +6 -2
  51. data/lib/capybara/session/matchers.rb +6 -6
  52. data/lib/capybara/spec/public/test.js +11 -0
  53. data/lib/capybara/spec/session/all_spec.rb +15 -0
  54. data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
  55. data/lib/capybara/spec/session/assert_text_spec.rb +4 -0
  56. data/lib/capybara/spec/session/click_button_spec.rb +5 -0
  57. data/lib/capybara/spec/session/find_spec.rb +20 -0
  58. data/lib/capybara/spec/session/has_table_spec.rb +51 -5
  59. data/lib/capybara/spec/session/has_text_spec.rb +31 -0
  60. data/lib/capybara/spec/session/node_spec.rb +15 -0
  61. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
  62. data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
  63. data/lib/capybara/spec/session/selectors_spec.rb +15 -2
  64. data/lib/capybara/spec/views/form.erb +5 -0
  65. data/lib/capybara/version.rb +1 -1
  66. data/spec/dsl_spec.rb +2 -2
  67. data/spec/minitest_spec_spec.rb +46 -46
  68. data/spec/regexp_dissassembler_spec.rb +45 -37
  69. data/spec/result_spec.rb +3 -3
  70. data/spec/rspec/features_spec.rb +1 -0
  71. data/spec/rspec/shared_spec_matchers.rb +3 -3
  72. data/spec/rspec_spec.rb +4 -4
  73. data/spec/selenium_spec_chrome.rb +3 -3
  74. data/spec/selenium_spec_firefox.rb +7 -2
  75. data/spec/server_spec.rb +42 -0
  76. data/spec/session_spec.rb +1 -1
  77. data/spec/shared_selenium_node.rb +3 -3
  78. data/spec/shared_selenium_session.rb +8 -7
  79. metadata +3 -3
@@ -15,7 +15,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
15
15
  @session.save_and_open_screenshot
16
16
 
17
17
  expect(@session.driver).to have_received(:save_screenshot)
18
- .with(expected_file_regex, {})
18
+ .with(expected_file_regex, any_args)
19
19
  expect(Launchy).to have_received(:open).with(expected_file_regex)
20
20
  end
21
21
 
@@ -27,7 +27,7 @@ Capybara::SpecHelper.spec '#save_and_open_screenshot' do
27
27
  @session.save_and_open_screenshot(custom_path)
28
28
 
29
29
  expect(@session.driver).to have_received(:save_screenshot)
30
- .with(/#{custom_path}$/, {})
30
+ .with(/#{custom_path}$/, any_args)
31
31
  expect(Launchy).to have_received(:open).with(/#{custom_path}$/)
32
32
  end
33
33
 
@@ -19,7 +19,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
19
19
  @session.save_screenshot
20
20
 
21
21
  regexp = Regexp.new(File.join(Dir.pwd, 'capybara-\d+\.png'))
22
- expect(@session.driver).to have_received(:save_screenshot).with(regexp, {})
22
+ expect(@session.driver).to have_received(:save_screenshot).with(regexp, any_args)
23
23
  end
24
24
 
25
25
  it 'allows to specify another path' do
@@ -28,7 +28,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
28
28
  custom_path = 'screenshots/1.png'
29
29
  @session.save_screenshot(custom_path)
30
30
 
31
- expect(@session.driver).to have_received(:save_screenshot).with(/#{custom_path}$/, {})
31
+ expect(@session.driver).to have_received(:save_screenshot).with(/#{custom_path}$/, any_args)
32
32
  end
33
33
 
34
34
  context 'with Capybara.save_path' do
@@ -39,7 +39,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
39
39
  @session.save_screenshot
40
40
 
41
41
  regexp = Regexp.new(File.join(alternative_path, 'capybara-\d+\.png'))
42
- expect(@session.driver).to have_received(:save_screenshot).with(regexp, {})
42
+ expect(@session.driver).to have_received(:save_screenshot).with(regexp, any_args)
43
43
  end
44
44
 
45
45
  it 'relative paths are relative to save_path' do
@@ -49,7 +49,7 @@ Capybara::SpecHelper.spec '#save_screenshot', requires: [:screenshot] do
49
49
  custom_path = 'screenshots/2.png'
50
50
  @session.save_screenshot(custom_path)
51
51
 
52
- expect(@session.driver).to have_received(:save_screenshot).with(File.expand_path(custom_path, alternative_path), {})
52
+ expect(@session.driver).to have_received(:save_screenshot).with(File.expand_path(custom_path, alternative_path), any_args)
53
53
  end
54
54
  end
55
55
  end
@@ -31,6 +31,11 @@ Capybara::SpecHelper.spec Capybara::Selector do
31
31
  expect(@session.find(:label, for: input).text).to eq 'Nested Label'
32
32
  end
33
33
 
34
+ it 'finds a label from nested input using :for filter with element when no id on label' do
35
+ input = @session.find(:css, '#wrapper_label').find(:css, 'input')
36
+ expect(@session.find(:label, for: input).text).to eq 'Wrapper Label'
37
+ end
38
+
34
39
  it 'finds the label for an non-nested element when using :for filter' do
35
40
  select = @session.find(:id, 'form_other_title')
36
41
  expect(@session.find(:label, for: select)['for']).to eq 'form_other_title'
@@ -62,14 +67,22 @@ Capybara::SpecHelper.spec Capybara::Selector do
62
67
  end
63
68
  end
64
69
 
65
- it 'can find specifically by name' do
70
+ it 'can find specifically by name string' do
66
71
  expect(@session.find(:field, name: 'form[other_title]')['id']).to eq 'form_other_title'
67
72
  end
68
73
 
69
- it 'can find specifically by placeholder' do
74
+ it 'can find specifically by name regex' do
75
+ expect(@session.find(:field, name: /form\[other_.*\]/)['id']).to eq 'form_other_title'
76
+ end
77
+
78
+ it 'can find specifically by placeholder string' do
70
79
  expect(@session.find(:field, placeholder: 'FirstName')['id']).to eq 'form_first_name'
71
80
  end
72
81
 
82
+ it 'can find specifically by placeholder regex' do
83
+ expect(@session.find(:field, placeholder: /FirstN.*/)['id']).to eq 'form_first_name'
84
+ end
85
+
73
86
  it 'can find by type' do
74
87
  expect(@session.find(:field, 'Confusion', type: 'checkbox')['id']).to eq 'confusion_checkbox'
75
88
  expect(@session.find(:field, 'Confusion', type: 'text')['id']).to eq 'confusion_text'
@@ -474,6 +474,11 @@ New line after and before textarea tag
474
474
  <input type="text" name="nested_label" id="nested_label"/>
475
475
  </label>
476
476
 
477
+ <label id="wrapper_label">
478
+ Wrapper Label
479
+ <input type="checkbox"/>
480
+ </label>
481
+
477
482
  <form id="form1" action="/form" method="post">
478
483
  <input type="text" name="form[which_form]" value="form1" id="form_which_form"/>
479
484
  <input type="text" name="form[for_form2]" value="for_form2" form="form2"/>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Capybara
4
- VERSION = '3.29.0'
4
+ VERSION = '3.30.0'
5
5
  end
@@ -92,7 +92,7 @@ RSpec.describe Capybara::DSL do
92
92
  driver_before_block = Capybara.current_driver
93
93
  begin
94
94
  Capybara.using_driver(:selenium) { raise 'ohnoes!' }
95
- rescue Exception # rubocop:disable Lint/RescueException,Lint/HandleExceptions
95
+ rescue Exception # rubocop:disable Lint/RescueException,Lint/SuppressedException
96
96
  end
97
97
  expect(Capybara.current_driver).to eq(driver_before_block)
98
98
  end
@@ -208,7 +208,7 @@ RSpec.describe Capybara::DSL do
208
208
  Capybara.using_session(:raise) do
209
209
  raise
210
210
  end
211
- rescue Exception # rubocop:disable Lint/RescueException,Lint/HandleExceptions
211
+ rescue Exception # rubocop:disable Lint/RescueException,Lint/SuppressedException
212
212
  end
213
213
  expect(Capybara.session_name).to eq(:default)
214
214
  end
@@ -17,125 +17,125 @@ class MinitestSpecTest < Minitest::Spec
17
17
  end
18
18
 
19
19
  it 'supports text expectations' do
20
- page.must_have_text('Form', minimum: 1)
21
- page.wont_have_text('Not a form')
20
+ _(page).must_have_text('Form', minimum: 1)
21
+ _(page).wont_have_text('Not a form')
22
22
  form = find(:css, 'form', text: 'Title')
23
- form.must_have_text('Customer Email')
24
- form.wont_have_text('Some other email')
23
+ _(form).must_have_text('Customer Email')
24
+ _(form).wont_have_text('Some other email')
25
25
  end
26
26
 
27
27
  it 'supports current_path expectations' do
28
- page.must_have_current_path('/form')
29
- page.wont_have_current_path('/form2')
28
+ _(page).must_have_current_path('/form')
29
+ _(page).wont_have_current_path('/form2')
30
30
  end
31
31
 
32
32
  it 'supports title expectations' do
33
33
  visit('/with_title')
34
- page.must_have_title('Test Title')
35
- page.wont_have_title('Not the title')
34
+ _(page).must_have_title('Test Title')
35
+ _(page).wont_have_title('Not the title')
36
36
  end
37
37
 
38
38
  it 'supports xpath expectations' do
39
- page.must_have_xpath('.//input[@id="customer_email"]')
40
- page.wont_have_xpath('.//select[@id="not_form_title"]')
41
- page.wont_have_xpath('.//input[@id="customer_email"]') { |el| el[:id] == 'not_customer_email' }
39
+ _(page).must_have_xpath('.//input[@id="customer_email"]')
40
+ _(page).wont_have_xpath('.//select[@id="not_form_title"]')
41
+ _(page).wont_have_xpath('.//input[@id="customer_email"]') { |el| el[:id] == 'not_customer_email' }
42
42
  select = find(:select, 'form_title')
43
- select.must_have_xpath('.//option[@class="title"]')
44
- select.must_have_xpath('.//option', count: 1) { |option| option[:class] != 'title' && !option.disabled? }
45
- select.wont_have_xpath('.//input[@id="customer_email"]')
43
+ _(select).must_have_xpath('.//option[@class="title"]')
44
+ _(select).must_have_xpath('.//option', count: 1) { |option| option[:class] != 'title' && !option.disabled? }
45
+ _(select).wont_have_xpath('.//input[@id="customer_email"]')
46
46
  end
47
47
 
48
48
  it 'support css expectations' do
49
- page.must_have_css('input#customer_email')
50
- page.wont_have_css('select#not_form_title')
49
+ _(page).must_have_css('input#customer_email')
50
+ _(page).wont_have_css('select#not_form_title')
51
51
  el = find(:select, 'form_title')
52
- el.must_have_css('option.title')
53
- el.wont_have_css('input#customer_email')
52
+ _(el).must_have_css('option.title')
53
+ _(el).wont_have_css('input#customer_email')
54
54
  end
55
55
 
56
56
  it 'supports link expectations' do
57
57
  visit('/with_html')
58
- page.must_have_link('A link')
59
- page.wont_have_link('Not on page')
58
+ _(page).must_have_link('A link')
59
+ _(page).wont_have_link('Not on page')
60
60
  end
61
61
 
62
62
  it 'supports button expectations' do
63
- page.must_have_button('fresh_btn')
64
- page.wont_have_button('not_btn')
63
+ _(page).must_have_button('fresh_btn')
64
+ _(page).wont_have_button('not_btn')
65
65
  end
66
66
 
67
67
  it 'supports field expectations' do
68
- page.must_have_field('customer_email')
69
- page.wont_have_field('not_on_the_form')
68
+ _(page).must_have_field('customer_email')
69
+ _(page).wont_have_field('not_on_the_form')
70
70
  end
71
71
 
72
72
  it 'supports select expectations' do
73
- page.must_have_select('form_title')
74
- page.wont_have_select('not_form_title')
73
+ _(page).must_have_select('form_title')
74
+ _(page).wont_have_select('not_form_title')
75
75
  end
76
76
 
77
77
  it 'supports checked_field expectations' do
78
- page.must_have_checked_field('form_pets_dog')
79
- page.wont_have_checked_field('form_pets_cat')
78
+ _(page).must_have_checked_field('form_pets_dog')
79
+ _(page).wont_have_checked_field('form_pets_cat')
80
80
  end
81
81
 
82
82
  it 'supports unchecked_field expectations' do
83
- page.must_have_unchecked_field('form_pets_cat')
84
- page.wont_have_unchecked_field('form_pets_dog')
83
+ _(page).must_have_unchecked_field('form_pets_cat')
84
+ _(page).wont_have_unchecked_field('form_pets_dog')
85
85
  end
86
86
 
87
87
  it 'supports table expectations' do
88
88
  visit('/tables')
89
- page.must_have_table('agent_table')
90
- page.wont_have_table('not_on_form')
89
+ _(page).must_have_table('agent_table')
90
+ _(page).wont_have_table('not_on_form')
91
91
  end
92
92
 
93
93
  it 'supports all_of_selectors expectations' do
94
- page.must_have_all_of_selectors(:css, 'select#form_other_title', 'input#form_last_name')
94
+ _(page).must_have_all_of_selectors(:css, 'select#form_other_title', 'input#form_last_name')
95
95
  end
96
96
 
97
97
  it 'supports none_of_selectors expectations' do
98
- page.must_have_none_of_selectors(:css, 'input#not_on_page', 'input#also_not_on_page')
98
+ _(page).must_have_none_of_selectors(:css, 'input#not_on_page', 'input#also_not_on_page')
99
99
  end
100
100
 
101
101
  it 'supports any_of_selectors expectations' do
102
- page.must_have_any_of_selectors(:css, 'select#form_other_title', 'input#not_on_page')
102
+ _(page).must_have_any_of_selectors(:css, 'select#form_other_title', 'input#not_on_page')
103
103
  end
104
104
 
105
105
  it 'supports match_selector expectations' do
106
- find(:field, 'customer_email').must_match_selector(:field, 'customer_email')
107
- find(:select, 'form_title').wont_match_selector(:field, 'customer_email')
106
+ _(find(:field, 'customer_email')).must_match_selector(:field, 'customer_email')
107
+ _(find(:select, 'form_title')).wont_match_selector(:field, 'customer_email')
108
108
  end
109
109
 
110
110
  it 'supports match_css expectations' do
111
- find(:select, 'form_title').must_match_css('select#form_title')
112
- find(:select, 'form_title').wont_match_css('select#form_other_title')
111
+ _(find(:select, 'form_title')).must_match_css('select#form_title')
112
+ _(find(:select, 'form_title')).wont_match_css('select#form_other_title')
113
113
  end
114
114
 
115
115
  it 'supports match_xpath expectations' do
116
- find(:select, 'form_title').must_match_xpath('.//select[@id="form_title"]')
117
- find(:select, 'form_title').wont_match_xpath('.//select[@id="not_on_page"]')
116
+ _(find(:select, 'form_title')).must_match_xpath('.//select[@id="form_title"]')
117
+ _(find(:select, 'form_title')).wont_match_xpath('.//select[@id="not_on_page"]')
118
118
  end
119
119
 
120
120
  it 'handles failures' do
121
- page.must_have_select('non_existing_form_title')
121
+ _(page).must_have_select('non_existing_form_title')
122
122
  end
123
123
 
124
124
  it 'supports style expectations' do
125
125
  skip "Rack test doesn't support style" if Capybara.current_driver == :rack_test
126
126
  visit('/with_html')
127
- find(:css, '#second').must_have_style('display' => 'inline') # deprecated
128
- find(:css, '#second').must_match_style('display' => 'inline')
127
+ _(find(:css, '#second')).must_have_style('display' => 'inline') # deprecated
128
+ _(find(:css, '#second')).must_match_style('display' => 'inline')
129
129
  end
130
130
 
131
131
  it 'supports ancestor expectations' do
132
132
  option = find(:option, 'Finnish')
133
- option.must_have_ancestor(:css, '#form_locale')
133
+ _(option).must_have_ancestor(:css, '#form_locale')
134
134
  end
135
135
 
136
136
  it 'supports sibling expectations' do
137
137
  option = find(:css, '#form_title').find(:option, 'Mrs')
138
- option.must_have_sibling(:option, 'Mr')
138
+ _(option).must_have_sibling(:option, 'Mr')
139
139
  end
140
140
  end
141
141
 
@@ -49,16 +49,20 @@ RSpec.describe Capybara::Selector::RegexpDisassembler, :aggregate_failures do
49
49
  end
50
50
 
51
51
  it 'handles optional characters for #alternated_substrings' do
52
+ # rubocop:disable Style/BracesAroundHashParameters
52
53
  verify_alternated_strings(
53
- /abc*def/ => [%w[ab def]],
54
- /abc*/ => [%w[ab]],
55
- /c*/ => [],
56
- /abc?def/ => [%w[abdef], %w[abcdef]],
57
- /abc?/ => [%w[ab]],
58
- /abc?def?/ => [%w[abde], %w[abcde]],
59
- /abc?def?g/ => [%w[abdeg], %w[abdefg], %w[abcdeg], %w[abcdefg]],
60
- /d?/ => []
54
+ {
55
+ /abc*def/ => [%w[ab def]],
56
+ /abc*/ => [%w[ab]],
57
+ /c*/ => [],
58
+ /abc?def/ => [%w[abdef], %w[abcdef]],
59
+ /abc?/ => [%w[ab]],
60
+ /abc?def?/ => [%w[abde], %w[abcde]],
61
+ /abc?def?g/ => [%w[abdeg], %w[abdefg], %w[abcdeg], %w[abcdefg]],
62
+ /d?/ => []
63
+ }
61
64
  )
65
+ # rubocop:enable Style/BracesAroundHashParameters
62
66
  end
63
67
 
64
68
  it 'handles character classes' do
@@ -136,36 +140,40 @@ RSpec.describe Capybara::Selector::RegexpDisassembler, :aggregate_failures do
136
140
  end
137
141
 
138
142
  it 'handles alternation for #alternated_substrings' do
143
+ # rubocop:disable Style/BracesAroundHashParameters
139
144
  verify_alternated_strings(
140
- /abc|def/ => [%w[abc], %w[def]],
141
- /ab(?:c|d)/ => [%w[abc], %w[abd]],
142
- /ab(c|d|e)fg/ => [%w[abcfg], %w[abdfg], %w[abefg]],
143
- /ab?(c|d)fg/ => [%w[acfg], %w[adfg], %w[abcfg], %w[abdfg]],
144
- /ab(c|d)ef/ => [%w[abcef], %w[abdef]],
145
- /ab(cd?|ef)g/ => [%w[abcg], %w[abcdg], %w[abefg]],
146
- /ab(cd|ef*)g/ => [%w[abcdg], %w[abe g]],
147
- /ab|cd*/ => [%w[ab], %w[c]],
148
- /cd(?:ef|gh)|xyz/ => [%w[cdef], %w[cdgh], %w[xyz]],
149
- /(cd(?:ef|gh)|xyz)/ => [%w[cdef], %w[cdgh], %w[xyz]],
150
- /cd(ef|gh)+/ => [%w[cdef], %w[cdgh]],
151
- /cd(ef|gh)?/ => [%w[cd]],
152
- /cd(ef|gh)?ij/ => [%w[cdij], %w[cdefij], %w[cdghij]],
153
- /cd(ef|gh)+ij/ => [%w[cdef ij], %w[cdgh ij]],
154
- /cd(ef|gh){2}ij/ => [%w[cdefefij], %w[cdefghij], %w[cdghefij], %w[cdghghij]],
155
- /(cd(ef|g*))/ => [%w[cd]],
156
- /a|b*/ => [],
157
- /ab(?:c|d?)/ => [%w[ab]],
158
- /ab(c|d)|a*/ => [],
159
- /(abc)?(d|e)/ => [%w[d], %w[e]],
160
- /(abc*de)?(d|e)/ => [%w[d], %w[e]],
161
- /(abc*de)?(d|e?)/ => [],
162
- /(abc)?(d|e?)/ => [],
163
- /ab(cd){0,2}ef/ => [%w[ab ef]],
164
- /ab(cd){0,1}ef/ => [%w[abef], %w[abcdef]],
165
- /ab(cd|cd)ef/ => [%w[abcdef]],
166
- /ab(cd|cd)?ef/ => [%w[abef], %w[abcdef]],
167
- /ab\\?cd/ => [%w[abcd], %w[ab\cd]]
168
- )
145
+ {
146
+ /abc|def/ => [%w[abc], %w[def]],
147
+ /ab(?:c|d)/ => [%w[abc], %w[abd]],
148
+ /ab(c|d|e)fg/ => [%w[abcfg], %w[abdfg], %w[abefg]],
149
+ /ab?(c|d)fg/ => [%w[acfg], %w[adfg], %w[abcfg], %w[abdfg]],
150
+ /ab(c|d)ef/ => [%w[abcef], %w[abdef]],
151
+ /ab(cd?|ef)g/ => [%w[abcg], %w[abcdg], %w[abefg]],
152
+ /ab(cd|ef*)g/ => [%w[abcdg], %w[abe g]],
153
+ /ab|cd*/ => [%w[ab], %w[c]],
154
+ /cd(?:ef|gh)|xyz/ => [%w[cdef], %w[cdgh], %w[xyz]],
155
+ /(cd(?:ef|gh)|xyz)/ => [%w[cdef], %w[cdgh], %w[xyz]],
156
+ /cd(ef|gh)+/ => [%w[cdef], %w[cdgh]],
157
+ /cd(ef|gh)?/ => [%w[cd]],
158
+ /cd(ef|gh)?ij/ => [%w[cdij], %w[cdefij], %w[cdghij]],
159
+ /cd(ef|gh)+ij/ => [%w[cdef ij], %w[cdgh ij]],
160
+ /cd(ef|gh){2}ij/ => [%w[cdefefij], %w[cdefghij], %w[cdghefij], %w[cdghghij]],
161
+ /(cd(ef|g*))/ => [%w[cd]],
162
+ /a|b*/ => [],
163
+ /ab(?:c|d?)/ => [%w[ab]],
164
+ /ab(c|d)|a*/ => [],
165
+ /(abc)?(d|e)/ => [%w[d], %w[e]],
166
+ /(abc*de)?(d|e)/ => [%w[d], %w[e]],
167
+ /(abc*de)?(d|e?)/ => [],
168
+ /(abc)?(d|e?)/ => [],
169
+ /ab(cd){0,2}ef/ => [%w[ab ef]],
170
+ /ab(cd){0,1}ef/ => [%w[abef], %w[abcdef]],
171
+ /ab(cd|cd)ef/ => [%w[abcdef]],
172
+ /ab(cd|cd)?ef/ => [%w[abef], %w[abcdef]],
173
+ /ab\\?cd/ => [%w[abcd], %w[ab\cd]]
174
+ }
175
+ )
176
+ # rubocop:enable Style/BracesAroundHashParameters
169
177
  end
170
178
 
171
179
  it 'handles grouping' do
@@ -44,9 +44,9 @@ RSpec.describe Capybara::Result do
44
44
  end
45
45
 
46
46
  it 'can be selected' do
47
- expect(result.select do |element|
47
+ expect(result.count do |element|
48
48
  element.text.include? 't'
49
- end.length).to eq(2)
49
+ end).to eq(2)
50
50
  end
51
51
 
52
52
  it 'can be reduced' do
@@ -137,7 +137,7 @@ RSpec.describe Capybara::Result do
137
137
  expect(result.instance_variable_get('@result_cache').size).to eq 4
138
138
  end
139
139
 
140
- context '#each' do
140
+ describe '#each' do
141
141
  it 'lazily evaluates' do
142
142
  skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
143
143
  results = []
@@ -81,6 +81,7 @@ xfeature 'if xfeature aliases to pending then' do
81
81
  scenario "this should be 'temporarily disabled with xfeature'" do
82
82
  # dummy
83
83
  end
84
+
84
85
  scenario "this also should be 'temporarily disabled with xfeature'" do
85
86
  # dummy
86
87
  end
@@ -857,7 +857,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
857
857
  session.visit('/with_js')
858
858
  end
859
859
 
860
- context '#and' do
860
+ describe '#and' do
861
861
  it "should run 'concurrently'" do
862
862
  Capybara.using_wait_time(2) do
863
863
  matcher = have_text('this is not there').and have_text('neither is this')
@@ -899,14 +899,14 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
899
899
  end
900
900
  end
901
901
 
902
- context '#and_then' do
902
+ describe '#and_then' do
903
903
  it 'should run sequentially' do
904
904
  session.click_link('reload-link')
905
905
  expect(el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
906
906
  end
907
907
  end
908
908
 
909
- context '#or' do
909
+ describe '#or' do
910
910
  it "should run 'concurrently'" do
911
911
  session.using_wait_time(3) do
912
912
  expect(Benchmark.realtime do