capybara 3.29.0 → 3.30.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.
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
@@ -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
@@ -29,7 +29,7 @@ Capybara.register_driver :selenium_chrome_not_clear_storage do |app|
29
29
  browser: :chrome,
30
30
  options: browser_options
31
31
  }
32
- Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: false, clear_session_storage: false))
32
+ Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_local_storage: false, clear_session_storage: false))
33
33
  end
34
34
 
35
35
  Capybara.register_driver :selenium_chrome_not_clear_session_storage do |app|
@@ -37,7 +37,7 @@ Capybara.register_driver :selenium_chrome_not_clear_session_storage do |app|
37
37
  browser: :chrome,
38
38
  options: browser_options
39
39
  }
40
- Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_session_storage: false))
40
+ Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_session_storage: false))
41
41
  end
42
42
 
43
43
  Capybara.register_driver :selenium_chrome_not_clear_local_storage do |app|
@@ -45,7 +45,7 @@ Capybara.register_driver :selenium_chrome_not_clear_local_storage do |app|
45
45
  browser: :chrome,
46
46
  options: browser_options
47
47
  }
48
- Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: false))
48
+ Capybara::Selenium::Driver.new(app, **chrome_options.merge(clear_local_storage: false))
49
49
  end
50
50
 
51
51
  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.30.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: 2019-12-25 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,