capybara 3.29.0 → 3.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +40 -1
  3. data/README.md +1 -1
  4. data/lib/capybara/config.rb +7 -3
  5. data/lib/capybara/dsl.rb +10 -2
  6. data/lib/capybara/helpers.rb +3 -1
  7. data/lib/capybara/minitest.rb +18 -4
  8. data/lib/capybara/node/actions.rb +23 -19
  9. data/lib/capybara/node/document.rb +2 -2
  10. data/lib/capybara/node/document_matchers.rb +3 -3
  11. data/lib/capybara/node/element.rb +21 -16
  12. data/lib/capybara/node/finders.rb +17 -11
  13. data/lib/capybara/node/matchers.rb +60 -45
  14. data/lib/capybara/node/simple.rb +4 -2
  15. data/lib/capybara/queries/ancestor_query.rb +1 -1
  16. data/lib/capybara/queries/base_query.rb +2 -1
  17. data/lib/capybara/queries/selector_query.rb +17 -4
  18. data/lib/capybara/queries/sibling_query.rb +1 -1
  19. data/lib/capybara/rack_test/browser.rb +4 -1
  20. data/lib/capybara/rack_test/driver.rb +1 -1
  21. data/lib/capybara/rack_test/form.rb +1 -1
  22. data/lib/capybara/rack_test/node.rb +34 -9
  23. data/lib/capybara/result.rb +24 -4
  24. data/lib/capybara/rspec/matchers.rb +27 -27
  25. data/lib/capybara/rspec/matchers/base.rb +12 -6
  26. data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
  27. data/lib/capybara/rspec/matchers/have_ancestor.rb +4 -3
  28. data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
  29. data/lib/capybara/rspec/matchers/have_selector.rb +15 -7
  30. data/lib/capybara/rspec/matchers/have_sibling.rb +3 -3
  31. data/lib/capybara/rspec/matchers/have_text.rb +2 -2
  32. data/lib/capybara/rspec/matchers/have_title.rb +2 -2
  33. data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
  34. data/lib/capybara/rspec/matchers/match_style.rb +2 -2
  35. data/lib/capybara/rspec/matchers/spatial_sugar.rb +2 -1
  36. data/lib/capybara/selector.rb +24 -16
  37. data/lib/capybara/selector/css.rb +1 -1
  38. data/lib/capybara/selector/definition.rb +2 -2
  39. data/lib/capybara/selector/definition/button.rb +7 -2
  40. data/lib/capybara/selector/definition/checkbox.rb +2 -2
  41. data/lib/capybara/selector/definition/css.rb +3 -1
  42. data/lib/capybara/selector/definition/datalist_input.rb +1 -1
  43. data/lib/capybara/selector/definition/datalist_option.rb +1 -1
  44. data/lib/capybara/selector/definition/element.rb +1 -1
  45. data/lib/capybara/selector/definition/field.rb +1 -1
  46. data/lib/capybara/selector/definition/file_field.rb +1 -1
  47. data/lib/capybara/selector/definition/fillable_field.rb +1 -1
  48. data/lib/capybara/selector/definition/label.rb +4 -2
  49. data/lib/capybara/selector/definition/radio_button.rb +2 -2
  50. data/lib/capybara/selector/definition/select.rb +32 -13
  51. data/lib/capybara/selector/definition/table.rb +5 -2
  52. data/lib/capybara/selector/filter_set.rb +11 -9
  53. data/lib/capybara/selector/filters/base.rb +6 -1
  54. data/lib/capybara/selector/filters/locator_filter.rb +1 -1
  55. data/lib/capybara/selector/selector.rb +4 -2
  56. data/lib/capybara/selenium/driver.rb +19 -11
  57. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +1 -1
  58. data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +2 -2
  59. data/lib/capybara/selenium/extensions/html5_drag.rb +30 -13
  60. data/lib/capybara/selenium/node.rb +29 -10
  61. data/lib/capybara/selenium/nodes/chrome_node.rb +11 -5
  62. data/lib/capybara/selenium/nodes/edge_node.rb +4 -2
  63. data/lib/capybara/selenium/nodes/firefox_node.rb +2 -2
  64. data/lib/capybara/server.rb +15 -3
  65. data/lib/capybara/server/checker.rb +1 -1
  66. data/lib/capybara/server/middleware.rb +20 -10
  67. data/lib/capybara/session.rb +40 -23
  68. data/lib/capybara/session/config.rb +6 -2
  69. data/lib/capybara/session/matchers.rb +6 -6
  70. data/lib/capybara/spec/public/test.js +51 -6
  71. data/lib/capybara/spec/session/all_spec.rb +60 -5
  72. data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
  73. data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
  74. data/lib/capybara/spec/session/click_button_spec.rb +5 -0
  75. data/lib/capybara/spec/session/fill_in_spec.rb +20 -0
  76. data/lib/capybara/spec/session/find_spec.rb +20 -0
  77. data/lib/capybara/spec/session/has_css_spec.rb +3 -3
  78. data/lib/capybara/spec/session/has_select_spec.rb +28 -0
  79. data/lib/capybara/spec/session/has_table_spec.rb +51 -5
  80. data/lib/capybara/spec/session/has_text_spec.rb +35 -0
  81. data/lib/capybara/spec/session/node_spec.rb +106 -2
  82. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
  83. data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -4
  84. data/lib/capybara/spec/session/selectors_spec.rb +15 -2
  85. data/lib/capybara/spec/views/form.erb +11 -1
  86. data/lib/capybara/version.rb +1 -1
  87. data/spec/dsl_spec.rb +2 -2
  88. data/spec/minitest_spec_spec.rb +46 -46
  89. data/spec/rack_test_spec.rb +0 -1
  90. data/spec/regexp_dissassembler_spec.rb +45 -37
  91. data/spec/result_spec.rb +7 -3
  92. data/spec/rspec/features_spec.rb +1 -0
  93. data/spec/rspec/shared_spec_matchers.rb +3 -3
  94. data/spec/rspec_spec.rb +4 -4
  95. data/spec/selenium_spec_chrome.rb +5 -4
  96. data/spec/selenium_spec_firefox.rb +7 -2
  97. data/spec/server_spec.rb +42 -0
  98. data/spec/session_spec.rb +1 -1
  99. data/spec/shared_selenium_node.rb +3 -3
  100. data/spec/shared_selenium_session.rb +8 -7
  101. metadata +3 -3
@@ -82,7 +82,6 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
82
82
  describe '#fill_in' do
83
83
  it 'should warn that :fill_options are not supported' do
84
84
  session.visit '/with_html'
85
-
86
85
  expect { session.fill_in 'test_field', with: 'not_monkey', fill_options: { random: true } }.to \
87
86
  output(/^Options passed to Node#set but the RackTest driver doesn't support any - ignoring/).to_stderr
88
87
  expect(session).to have_field('test_field', with: 'not_monkey')
@@ -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
@@ -78,6 +78,10 @@ RSpec.describe Capybara::Result do
78
78
  eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.5
79
79
  expect(result[2..].map(&:text)).to eq %w[Gamma Delta]
80
80
  TEST
81
+ eval <<~TEST, binding, __FILE__, __LINE__ + 1 if RUBY_VERSION.to_f > 2.6
82
+ expect(result[..2].map(&:text)).to eq %w[Alpha Beta Gamma]
83
+ expect(result[...2].map(&:text)).to eq %w[Alpha Beta]
84
+ TEST
81
85
  end
82
86
 
83
87
  it 'works with filter blocks' do
@@ -137,7 +141,7 @@ RSpec.describe Capybara::Result do
137
141
  expect(result.instance_variable_get('@result_cache').size).to eq 4
138
142
  end
139
143
 
140
- context '#each' do
144
+ describe '#each' do
141
145
  it 'lazily evaluates' do
142
146
  skip 'JRuby has an issue with lazy enumerator evaluation' if jruby_lazy_enumerator_workaround?
143
147
  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
@@ -43,7 +43,7 @@ RSpec.describe 'capybara/rspec' do
43
43
  expect(Capybara.current_driver).to eq(:culerity)
44
44
  end
45
45
 
46
- context '#all' do
46
+ describe '#all' do
47
47
  it 'allows access to the Capybara finder' do
48
48
  visit('/with_html')
49
49
  found = all(:css, 'h2') { |element| element[:class] == 'head' }
@@ -57,7 +57,7 @@ RSpec.describe 'capybara/rspec' do
57
57
  end
58
58
  end
59
59
 
60
- context '#within' do
60
+ describe '#within' do
61
61
  it 'allows access to the Capybara scoper' do
62
62
  visit('/with_html')
63
63
  expect do
@@ -82,7 +82,7 @@ RSpec.describe 'capybara/rspec' do
82
82
  end.new
83
83
  end
84
84
 
85
- context '#all' do
85
+ describe '#all' do
86
86
  it 'allows access to the Capybara finder' do
87
87
  test_class_instance.visit('/with_html')
88
88
  expect(test_class_instance.all(:css, 'h2.head').size).to eq(5)
@@ -95,7 +95,7 @@ RSpec.describe 'capybara/rspec' do
95
95
  end
96
96
  end
97
97
 
98
- context '#within' do
98
+ describe '#within' do
99
99
  it 'allows access to the Capybara scoper' do
100
100
  test_class_instance.visit('/with_html')
101
101
  expect do
@@ -14,7 +14,8 @@ browser_options = ::Selenium::WebDriver::Chrome::Options.new
14
14
  browser_options.headless! if ENV['HEADLESS']
15
15
  browser_options.add_option(:w3c, ENV['W3C'] != 'false')
16
16
  # Chromedriver 77 requires setting this for headless mode on linux
17
- # browser_options.add_preference('download.default_directory', Capybara.save_path)
17
+ # Different versions of Chrome/selenium-webdriver require setting differently - jus set them all
18
+ browser_options.add_preference('download.default_directory', Capybara.save_path)
18
19
  browser_options.add_preference(:download, default_directory: Capybara.save_path)
19
20
 
20
21
  Capybara.register_driver :selenium_chrome do |app|
@@ -29,7 +30,7 @@ Capybara.register_driver :selenium_chrome_not_clear_storage do |app|
29
30
  browser: :chrome,
30
31
  options: browser_options
31
32
  }
32
- Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: false, clear_session_storage: false))
33
+ Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_local_storage: false, clear_session_storage: false))
33
34
  end
34
35
 
35
36
  Capybara.register_driver :selenium_chrome_not_clear_session_storage do |app|
@@ -37,7 +38,7 @@ Capybara.register_driver :selenium_chrome_not_clear_session_storage do |app|
37
38
  browser: :chrome,
38
39
  options: browser_options
39
40
  }
40
- Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_session_storage: false))
41
+ Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_session_storage: false))
41
42
  end
42
43
 
43
44
  Capybara.register_driver :selenium_chrome_not_clear_local_storage do |app|
@@ -45,7 +46,7 @@ Capybara.register_driver :selenium_chrome_not_clear_local_storage do |app|
45
46
  browser: :chrome,
46
47
  options: browser_options
47
48
  }
48
- Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: false))
49
+ Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_local_storage: false))
49
50
  end
50
51
 
51
52
  Capybara.register_driver :selenium_driver_subclass_with_chrome do |app|
@@ -49,7 +49,7 @@ Capybara::SpecHelper.log_selenium_driver_version(Selenium::WebDriver::Firefox) i
49
49
  Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capybara_skip: skipped_tests do |example|
50
50
  case example.metadata[:full_description]
51
51
  when 'Capybara::Session selenium node #click should allow multiple modifiers'
52
- pending "Firefox doesn't generate an event for shift+control+click" if firefox_gte?(62, @session) && !Gem.win_platform?
52
+ pending "Firefox on OSX doesn't generate an event for shift+control+click" if firefox_gte?(62, @session) && Selenium::WebDriver::Platform.mac?
53
53
  when /^Capybara::Session selenium node #double_click/
54
54
  pending "selenium-webdriver/geckodriver doesn't generate double click event" if firefox_lt?(59, @session)
55
55
  when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default'
@@ -58,12 +58,17 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capyba
58
58
  pending "FF < 62 doesn't support setting all files at once" if firefox_lt?(62, @session)
59
59
  when 'Capybara::Session selenium #accept_confirm should work with nested modals'
60
60
  skip 'Broken in 63 <= FF < 69 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if firefox_gte?(63, @session) && firefox_lt?(69, @session)
61
+ skip 'Hangs in 69 <= FF < 71 - Dont know what issue for this - previous issue was closed as fixed but it is not' if firefox_gte?(69, @session) && firefox_lt?(71, @session)
62
+ skip 'Broken again intermittently in FF 71 - jus skip it'
61
63
  when 'Capybara::Session selenium #click_link can download a file'
62
64
  skip 'Need to figure out testing of file downloading on windows platform' if Gem.win_platform?
63
65
  when 'Capybara::Session selenium #reset_session! removes ALL cookies'
64
66
  pending "Geckodriver doesn't provide a way to remove cookies outside the current domain"
65
67
  when /drag_to.*HTML5/
66
68
  pending "Firefox < 62 doesn't support a DataTransfer constuctor" if firefox_lt?(62.0, @session)
69
+ when 'Capybara::Session selenium #accept_alert should handle the alert if the page changes',
70
+ 'Capybara::Session selenium #accept_alert with an asynchronous alert should accept the alert'
71
+ skip 'No clue what Firefox is doing here - works fine on MacOS locally'
67
72
  end
68
73
  end
69
74
 
@@ -181,7 +186,7 @@ RSpec.describe Capybara::Selenium::Driver do
181
186
  end
182
187
 
183
188
  RSpec.describe Capybara::Selenium::Node do
184
- context '#click' do
189
+ describe '#click' do
185
190
  it 'warns when attempting on a table row' do
186
191
  session = TestSessions::SeleniumFirefox
187
192
  session.visit('/tables')
@@ -74,6 +74,28 @@ RSpec.describe Capybara::Server do
74
74
  end
75
75
  end
76
76
 
77
+ it 'should handle that getting available ports fails randomly' do
78
+ begin
79
+ # Use a port to force a EADDRINUSE error to be generated
80
+ server = TCPServer.new('0.0.0.0', 0)
81
+ server_port = server.addr[1]
82
+ d_server = instance_double('TCPServer', addr: [nil, server_port, nil, nil], close: nil)
83
+ call_count = 0
84
+ allow(TCPServer).to receive(:new).and_wrap_original do |m, *args|
85
+ begin
86
+ call_count.zero? ? d_server : m.call(*args)
87
+ ensure
88
+ call_count += 1
89
+ end
90
+ end
91
+
92
+ port = described_class.new(Object.new, host: '0.0.0.0').port
93
+ expect(port).not_to eq(server_port)
94
+ ensure
95
+ server&.close
96
+ end
97
+ end
98
+
77
99
  it 'should return its #base_url' do
78
100
  app = proc { |_env| [200, {}, ['Hello Server!']] }
79
101
  server = described_class.new(app).boot
@@ -217,6 +239,26 @@ RSpec.describe Capybara::Server do
217
239
  end
218
240
  end
219
241
 
242
+ it 'should raise an error when there are pending requests' do
243
+ app = proc do |env|
244
+ request = Rack::Request.new(env)
245
+ sleep request.params['wait_time'].to_f
246
+ [200, {}, ['Hello Server!']]
247
+ end
248
+
249
+ server = described_class.new(app).boot
250
+
251
+ expect do
252
+ start_request(server, 59.0)
253
+ server.wait_for_pending_requests
254
+ end.not_to raise_error
255
+
256
+ expect do
257
+ start_request(server, 61.0)
258
+ server.wait_for_pending_requests
259
+ end.to raise_error('Requests did not finish in 60 seconds: ["/?wait_time=61.0"]')
260
+ end
261
+
220
262
  it 'is not #responsive? when Net::HTTP raises a SystemCallError' do
221
263
  app = -> { [200, {}, ['Hello, world']] }
222
264
  server = described_class.new(app)
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Capybara::Session do
6
- context '#new' do
6
+ describe '#new' do
7
7
  it 'should raise an error if passed non-existent driver' do
8
8
  expect do
9
9
  described_class.new(:quox, TestApp).driver
@@ -6,7 +6,7 @@ require 'selenium-webdriver'
6
6
  RSpec.shared_examples 'Capybara::Node' do |session, _mode|
7
7
  let(:session) { session }
8
8
 
9
- context '#content_editable?' do
9
+ describe '#content_editable?' do
10
10
  it 'returns true when the element is content editable' do
11
11
  session.visit('/with_js')
12
12
  expect(session.find(:css, '#existing_content_editable').base.content_editable?).to be true
@@ -19,7 +19,7 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
19
19
  end
20
20
  end
21
21
 
22
- context '#send_keys' do
22
+ describe '#send_keys' do
23
23
  it 'should process space' do
24
24
  session.visit('/form')
25
25
  session.find(:css, '#address1_city').send_keys('ocean', [:shift, :space, 'side'])
@@ -27,7 +27,7 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
27
27
  end
28
28
  end
29
29
 
30
- context '#visible?' do
30
+ describe '#visible?' do
31
31
  let(:bridge) do
32
32
  session.driver.browser.send(:bridge)
33
33
  end
@@ -72,7 +72,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
72
72
  end
73
73
  end
74
74
 
75
- context '#fill_in_with empty string and no options' do
75
+ describe '#fill_in_with empty string and no options' do
76
76
  it 'should trigger change when clearing a field' do
77
77
  pending "safaridriver doesn't trigger change for clear" if safari?(session)
78
78
  session.visit('/with_js')
@@ -83,7 +83,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
83
83
  end
84
84
  end
85
85
 
86
- context '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
86
+ describe '#fill_in with { :clear => :backspace } fill_option', requires: [:js] do
87
87
  before do
88
88
  # Firefox has an issue with change events if the main window doesn't think it's focused
89
89
  session.execute_script('window.focus()')
@@ -150,7 +150,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
150
150
  end
151
151
  end
152
152
 
153
- context '#fill_in with { clear: :none } fill_options' do
153
+ describe '#fill_in with { clear: :none } fill_options' do
154
154
  it 'should append to content in a field' do
155
155
  pending 'Safari overwrites by default - need to figure out a workaround' if safari?(session)
156
156
 
@@ -162,7 +162,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
162
162
  end
163
163
  end
164
164
 
165
- context '#fill_in with Date' do
165
+ describe '#fill_in with Date' do
166
166
  before do
167
167
  session.visit('/form')
168
168
  session.find(:css, '#form_date').execute_script <<-JS
@@ -194,7 +194,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
194
194
  end
195
195
  end
196
196
 
197
- context '#fill_in with { clear: Array } fill_options' do
197
+ describe '#fill_in with { clear: Array } fill_options' do
198
198
  it 'should pass the array through to the element' do
199
199
  # this is mainly for use with [[:control, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
200
200
  session.visit('/form')
@@ -299,8 +299,9 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
299
299
  describe 'Element#click' do
300
300
  it 'should handle fixed headers/footers' do
301
301
  session.visit('/with_fixed_header_footer')
302
- # session.click_link('Go to root')
303
- session.find(:link, 'Go to root').click
302
+ session.using_wait_time(2) do
303
+ session.find(:link, 'Go to root').click
304
+ end
304
305
  expect(session).to have_current_path('/')
305
306
  end
306
307
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.29.0
4
+ version: 3.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Walpole
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - gem-public_cert.pem
13
- date: 2019-09-02 00:00:00.000000000 Z
13
+ date: 2020-01-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -744,7 +744,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
744
744
  - !ruby/object:Gem::Version
745
745
  version: '0'
746
746
  requirements: []
747
- rubygems_version: 3.0.6
747
+ rubygems_version: 3.1.2
748
748
  signing_key:
749
749
  specification_version: 4
750
750
  summary: Capybara aims to simplify the process of integration testing Rack applications,