capybara 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +16 -0
  3. data/README.md +5 -7
  4. data/lib/capybara.rb +7 -6
  5. data/lib/capybara/config.rb +1 -1
  6. data/lib/capybara/dsl.rb +2 -2
  7. data/lib/capybara/helpers.rb +3 -3
  8. data/lib/capybara/minitest/spec.rb +3 -3
  9. data/lib/capybara/node/actions.rb +18 -18
  10. data/lib/capybara/node/base.rb +1 -1
  11. data/lib/capybara/node/element.rb +2 -2
  12. data/lib/capybara/node/finders.rb +6 -6
  13. data/lib/capybara/node/matchers.rb +5 -5
  14. data/lib/capybara/node/simple.rb +2 -2
  15. data/lib/capybara/queries/ancestor_query.rb +1 -1
  16. data/lib/capybara/queries/base_query.rb +12 -11
  17. data/lib/capybara/queries/current_path_query.rb +1 -1
  18. data/lib/capybara/queries/selector_query.rb +39 -15
  19. data/lib/capybara/queries/sibling_query.rb +1 -1
  20. data/lib/capybara/queries/text_query.rb +1 -1
  21. data/lib/capybara/rack_test/browser.rb +7 -7
  22. data/lib/capybara/rack_test/driver.rb +1 -1
  23. data/lib/capybara/rack_test/form.rb +7 -7
  24. data/lib/capybara/rack_test/node.rb +16 -16
  25. data/lib/capybara/rails.rb +1 -1
  26. data/lib/capybara/result.rb +8 -4
  27. data/lib/capybara/rspec/features.rb +4 -4
  28. data/lib/capybara/rspec/matchers.rb +6 -6
  29. data/lib/capybara/selector.rb +106 -90
  30. data/lib/capybara/selector/css.rb +4 -4
  31. data/lib/capybara/selector/filter_set.rb +52 -8
  32. data/lib/capybara/selector/selector.rb +39 -15
  33. data/lib/capybara/selenium/driver.rb +10 -10
  34. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +8 -0
  35. data/lib/capybara/selenium/node.rb +9 -10
  36. data/lib/capybara/selenium/nodes/chrome_node.rb +18 -0
  37. data/lib/capybara/selenium/nodes/marionette_node.rb +32 -7
  38. data/lib/capybara/server.rb +3 -3
  39. data/lib/capybara/server/animation_disabler.rb +1 -1
  40. data/lib/capybara/server/middleware.rb +1 -1
  41. data/lib/capybara/session.rb +23 -19
  42. data/lib/capybara/session/config.rb +18 -3
  43. data/lib/capybara/spec/public/test.js +1 -1
  44. data/lib/capybara/spec/session/accept_alert_spec.rb +10 -10
  45. data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -3
  46. data/lib/capybara/spec/session/accept_prompt_spec.rb +9 -10
  47. data/lib/capybara/spec/session/all_spec.rb +33 -32
  48. data/lib/capybara/spec/session/ancestor_spec.rb +19 -19
  49. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +38 -38
  50. data/lib/capybara/spec/session/assert_current_path_spec.rb +16 -16
  51. data/lib/capybara/spec/session/assert_selector_spec.rb +53 -53
  52. data/lib/capybara/spec/session/assert_style_spec.rb +3 -3
  53. data/lib/capybara/spec/session/assert_text_spec.rb +31 -30
  54. data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
  55. data/lib/capybara/spec/session/attach_file_spec.rb +51 -52
  56. data/lib/capybara/spec/session/body_spec.rb +6 -6
  57. data/lib/capybara/spec/session/check_spec.rb +52 -47
  58. data/lib/capybara/spec/session/choose_spec.rb +32 -32
  59. data/lib/capybara/spec/session/click_button_spec.rb +103 -103
  60. data/lib/capybara/spec/session/click_link_or_button_spec.rb +24 -23
  61. data/lib/capybara/spec/session/click_link_spec.rb +49 -48
  62. data/lib/capybara/spec/session/current_scope_spec.rb +7 -7
  63. data/lib/capybara/spec/session/current_url_spec.rb +26 -27
  64. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +3 -3
  65. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -2
  66. data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +8 -8
  67. data/lib/capybara/spec/session/element/match_css_spec.rb +10 -10
  68. data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
  69. data/lib/capybara/spec/session/element/matches_selector_spec.rb +51 -51
  70. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
  71. data/lib/capybara/spec/session/evaluate_script_spec.rb +15 -8
  72. data/lib/capybara/spec/session/execute_script_spec.rb +7 -7
  73. data/lib/capybara/spec/session/fill_in_spec.rb +43 -42
  74. data/lib/capybara/spec/session/find_button_spec.rb +23 -23
  75. data/lib/capybara/spec/session/find_by_id_spec.rb +7 -7
  76. data/lib/capybara/spec/session/find_field_spec.rb +32 -30
  77. data/lib/capybara/spec/session/find_link_spec.rb +21 -21
  78. data/lib/capybara/spec/session/find_spec.rb +153 -135
  79. data/lib/capybara/spec/session/first_spec.rb +41 -41
  80. data/lib/capybara/spec/session/frame/frame_title_spec.rb +5 -5
  81. data/lib/capybara/spec/session/frame/frame_url_spec.rb +5 -5
  82. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +17 -17
  83. data/lib/capybara/spec/session/frame/within_frame_spec.rb +31 -17
  84. data/lib/capybara/spec/session/go_back_spec.rb +1 -1
  85. data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
  86. data/lib/capybara/spec/session/has_all_selectors_spec.rb +17 -17
  87. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  88. data/lib/capybara/spec/session/has_css_spec.rb +133 -131
  89. data/lib/capybara/spec/session/has_current_path_spec.rb +29 -29
  90. data/lib/capybara/spec/session/has_field_spec.rb +58 -58
  91. data/lib/capybara/spec/session/has_link_spec.rb +4 -4
  92. data/lib/capybara/spec/session/has_none_selectors_spec.rb +24 -24
  93. data/lib/capybara/spec/session/has_select_spec.rb +43 -43
  94. data/lib/capybara/spec/session/has_selector_spec.rb +71 -71
  95. data/lib/capybara/spec/session/has_style_spec.rb +3 -3
  96. data/lib/capybara/spec/session/has_table_spec.rb +4 -4
  97. data/lib/capybara/spec/session/has_text_spec.rb +53 -52
  98. data/lib/capybara/spec/session/has_title_spec.rb +14 -14
  99. data/lib/capybara/spec/session/has_xpath_spec.rb +39 -38
  100. data/lib/capybara/spec/session/headers_spec.rb +1 -1
  101. data/lib/capybara/spec/session/html_spec.rb +6 -6
  102. data/lib/capybara/spec/session/node_spec.rb +129 -123
  103. data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
  104. data/lib/capybara/spec/session/refresh_spec.rb +4 -7
  105. data/lib/capybara/spec/session/reset_session_spec.rb +28 -28
  106. data/lib/capybara/spec/session/response_code_spec.rb +1 -1
  107. data/lib/capybara/spec/session/save_and_open_page_spec.rb +2 -2
  108. data/lib/capybara/spec/session/save_page_spec.rb +37 -37
  109. data/lib/capybara/spec/session/save_screenshot_spec.rb +6 -6
  110. data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
  111. data/lib/capybara/spec/session/select_spec.rb +81 -81
  112. data/lib/capybara/spec/session/selectors_spec.rb +17 -17
  113. data/lib/capybara/spec/session/sibling_spec.rb +9 -9
  114. data/lib/capybara/spec/session/text_spec.rb +23 -23
  115. data/lib/capybara/spec/session/title_spec.rb +5 -5
  116. data/lib/capybara/spec/session/uncheck_spec.rb +24 -20
  117. data/lib/capybara/spec/session/unselect_spec.rb +37 -37
  118. data/lib/capybara/spec/session/visit_spec.rb +48 -49
  119. data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
  120. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -16
  121. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -2
  122. data/lib/capybara/spec/session/window/window_spec.rb +4 -4
  123. data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
  124. data/lib/capybara/spec/session/within_spec.rb +41 -41
  125. data/lib/capybara/spec/spec_helper.rb +11 -9
  126. data/lib/capybara/spec/test_app.rb +18 -17
  127. data/lib/capybara/spec/views/form.erb +29 -31
  128. data/lib/capybara/spec/views/with_html.erb +2 -2
  129. data/lib/capybara/version.rb +1 -1
  130. data/spec/basic_node_spec.rb +23 -23
  131. data/spec/capybara_spec.rb +20 -20
  132. data/spec/css_splitter_spec.rb +7 -7
  133. data/spec/dsl_spec.rb +37 -32
  134. data/spec/filter_set_spec.rb +4 -4
  135. data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
  136. data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
  137. data/spec/minitest_spec.rb +4 -4
  138. data/spec/minitest_spec_spec.rb +23 -23
  139. data/spec/per_session_config_spec.rb +5 -5
  140. data/spec/rack_test_spec.rb +44 -44
  141. data/spec/result_spec.rb +14 -14
  142. data/spec/rspec/features_spec.rb +13 -13
  143. data/spec/rspec/scenarios_spec.rb +4 -4
  144. data/spec/rspec/shared_spec_matchers.rb +282 -281
  145. data/spec/rspec/views_spec.rb +3 -3
  146. data/spec/rspec_matchers_spec.rb +10 -10
  147. data/spec/rspec_spec.rb +29 -29
  148. data/spec/selector_spec.rb +64 -64
  149. data/spec/selenium_spec_chrome.rb +14 -22
  150. data/spec/selenium_spec_chrome_remote.rb +28 -8
  151. data/spec/selenium_spec_edge.rb +9 -4
  152. data/spec/selenium_spec_firefox_remote.rb +87 -0
  153. data/spec/selenium_spec_ie.rb +9 -4
  154. data/spec/selenium_spec_marionette.rb +42 -18
  155. data/spec/server_spec.rb +29 -27
  156. data/spec/session_spec.rb +17 -17
  157. data/spec/shared_selenium_session.rb +70 -52
  158. data/spec/spec_helper.rb +1 -1
  159. metadata +4 -2
@@ -57,7 +57,7 @@ class TestApp < Sinatra::Base
57
57
  end
58
58
 
59
59
  get '/get_referer' do
60
- request.referer.nil? ? "No referer" : "Got referer: #{request.referer}"
60
+ request.referer.nil? ? 'No referer' : "Got referer: #{request.referer}"
61
61
  end
62
62
 
63
63
  get '/host' do
@@ -67,14 +67,14 @@ class TestApp < Sinatra::Base
67
67
  get '/redirect/:times/times' do
68
68
  times = params[:times].to_i
69
69
  if times.zero?
70
- "redirection complete"
70
+ 'redirection complete'
71
71
  else
72
72
  redirect "/redirect/#{times - 1}/times"
73
73
  end
74
74
  end
75
75
 
76
76
  get '/landed' do
77
- "You landed"
77
+ 'You landed'
78
78
  end
79
79
 
80
80
  post '/landed' do
@@ -101,12 +101,12 @@ class TestApp < Sinatra::Base
101
101
  redirect '/redirect_again'
102
102
  end
103
103
 
104
- delete "/delete" do
105
- "The requested object was deleted"
104
+ delete '/delete' do
105
+ 'The requested object was deleted'
106
106
  end
107
107
 
108
- get "/delete" do
109
- "Not deleted"
108
+ get '/delete' do
109
+ 'Not deleted'
110
110
  end
111
111
 
112
112
  get '/redirect_back' do
@@ -141,11 +141,11 @@ class TestApp < Sinatra::Base
141
141
  end
142
142
 
143
143
  get '/error' do
144
- raise TestAppError, "some error"
144
+ raise TestAppError, 'some error'
145
145
  end
146
146
 
147
147
  get '/other_error' do
148
- raise TestAppOtherError.new("something", "other error")
148
+ raise TestAppOtherError.new('something', 'other error')
149
149
  end
150
150
 
151
151
  get '/load_error' do
@@ -166,7 +166,7 @@ class TestApp < Sinatra::Base
166
166
  end
167
167
 
168
168
  get '/download.csv' do
169
- content_type "text/csv"
169
+ content_type 'text/csv'
170
170
  'This, is, comma, separated' \
171
171
  'Thomas, Walpole, was , here'
172
172
  end
@@ -177,7 +177,7 @@ class TestApp < Sinatra::Base
177
177
 
178
178
  post '/form' do
179
179
  @@form_post_count += 1
180
- '<pre id="results">' + params[:form].merge("post_count" => @@form_post_count).to_yaml + '</pre>'
180
+ '<pre id="results">' + params[:form].merge('post_count' => @@form_post_count).to_yaml + '</pre>'
181
181
  end
182
182
 
183
183
  post '/upload_empty' do
@@ -191,23 +191,24 @@ class TestApp < Sinatra::Base
191
191
  post '/upload' do
192
192
  begin
193
193
  buffer = []
194
- buffer << "Content-type: #{params[:form][:document][:type]}"
195
- buffer << "File content: #{params[:form][:document][:tempfile].read}"
194
+ buffer << "Content-type: #{params.dig(:form, :document, :type)}"
195
+ buffer << "File content: #{params.dig(:form, :document, :tempfile).read}"
196
196
  buffer.join(' | ')
197
- rescue
197
+ rescue StandardError
198
198
  'No file uploaded'
199
199
  end
200
200
  end
201
201
 
202
202
  post '/upload_multiple' do
203
203
  begin
204
- buffer = [params[:form][:multiple_documents].size.to_s]
205
- params[:form][:multiple_documents].each do |doc|
204
+ docs = params.dig(:form, :multiple_documents)
205
+ buffer = [docs.size.to_s]
206
+ docs.each do |doc|
206
207
  buffer << "Content-type: #{doc[:type]}"
207
208
  buffer << "File content: #{doc[:tempfile].read}"
208
209
  end
209
210
  buffer.join(' | ')
210
- rescue
211
+ rescue StandardError
211
212
  'No files uploaded'
212
213
  end
213
214
  end
@@ -195,6 +195,8 @@ New line after and before textarea tag
195
195
  Koenigsegg
196
196
  <input type="checkbox" value="koenigsegg" name="form[cars][]" id="form_cars_koenigsegg" checked="checked" style="display: none"/>
197
197
  </label>
198
+ <input type="checkbox" value="maserati" name="form[cars][]" id="form_cars_maserati" disabled="disabled"/>
199
+ <label for="form_cars_maserati">Maserati</label>
198
200
  </p>
199
201
 
200
202
  <p>
@@ -370,7 +372,6 @@ New line after and before textarea tag
370
372
  </label>
371
373
  </p>
372
374
 
373
-
374
375
  <p>
375
376
  <label for="form_disabled_file">
376
377
  Disabled File
@@ -378,41 +379,38 @@ New line after and before textarea tag
378
379
  </label>
379
380
  </p>
380
381
 
381
- <p>
382
- <fieldset>
383
- <input name="form[enabled_fieldset_child]" id="form_enabled_fieldset_child"/>
384
- </fieldset>
385
- </p>
382
+ <fieldset>
383
+ <input name="form[enabled_fieldset_child]" id="form_enabled_fieldset_child"/>
384
+ </fieldset>
386
385
 
387
-
388
- <p>
389
- <fieldset disabled="disabled" id="form_disabled_fieldset">
390
- <legend>Disabled Child</legend>
391
- <input name="form[disabled_fieldset_child]" id="form_disabled_fieldset_child"/>
392
- <select>
393
- <option>Disabled Child Option</option>
394
- </select>
395
- </fieldset>
396
-
397
- <fieldset disabled="disabled">
398
- <legend>
399
- Nested Disabled
400
- <input type="checkbox" name="form[disabled_fieldeset_legend_child]" id="form_disabled_fieldset_legend_child"/>
401
- </legend>
386
+ <fieldset disabled="disabled" id="form_disabled_fieldset">
387
+ <legend>Disabled Child</legend>
388
+ <input name="form[disabled_fieldset_child]" id="form_disabled_fieldset_child"/>
389
+ <select>
390
+ <option>Disabled Child Option</option>
391
+ </select>
392
+ </fieldset>
393
+
394
+ <fieldset disabled="disabled">
395
+ <legend>
396
+ Nested Disabled
397
+ <input type="checkbox" name="form[disabled_fieldeset_legend_child]" id="form_disabled_fieldset_legend_child"/>
398
+ </legend>
399
+ <legend>
400
+ Another WLegend
401
+ <input type="checkbox" name="form[disabled_fieldeset_second_legend_child]" id="form_disabled_fieldset_second_legend_child"/>
402
+ </legend>
403
+ <fieldset>
402
404
  <legend>
403
- Another Legend
404
- <input type="checkbox" name="form[disabled_fieldeset_second_legend_child]" id="form_disabled_fieldset_second_legend_child"/>
405
+ Disabled?
406
+ <input id="form_disabled_fieldset_descendant_legend_child">
405
407
  </legend>
406
- <p>
407
- <fieldset>
408
- <input name="form[disabled_fieldset_descendant]" id="form_disabled_fieldset_descendant"/>
409
- </fieldset>
410
- </p>
408
+ <input name="form[disabled_fieldset_descendant]" id="form_disabled_fieldset_descendant"/>
411
409
  </fieldset>
412
- </p>
410
+ </fieldset>
413
411
 
414
412
  <p>
415
- <select>
413
+ <select data-test-id="my_test_id">
416
414
  <optgroup label="Level One">
417
415
  <option> A.1 </option>
418
416
  </optgroup>
@@ -461,7 +459,7 @@ New line after and before textarea tag
461
459
  </form>
462
460
 
463
461
  <form id="form2" action="/form" method="post">
464
- <input type="text" name="form[which_form]" value="form2" id="form_which_form"/>
462
+ <input type="text" name="form[which_form]" value="form2" id="form_which_form2"/>
465
463
  <input type="submit" name="form[unused]" value="unused"/>
466
464
  <button type="submit" name="form[other_form_button]" value="other_form_button" form="form1">Form1</button>
467
465
  </form>
@@ -36,9 +36,9 @@
36
36
  </p>
37
37
 
38
38
  <p>
39
- <input type="text" id="test_field" value="monkey"/>
39
+ <input type="text" id="test_field" data-test-id="test_id" value="monkey"/>
40
40
  <input type="text" readonly="readonly" value="should not change" />
41
- <textarea id="normal">
41
+ <textarea id="normal" data-other-test-id="test_id">
42
42
  banana</textarea>
43
43
  <textarea id="additional_newline">
44
44
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Capybara
4
- VERSION = '3.3.1'
4
+ VERSION = '3.4.0'
5
5
  end
@@ -46,19 +46,19 @@ RSpec.describe Capybara do
46
46
  STRING
47
47
  end
48
48
 
49
- it "allows using matchers" do
49
+ it 'allows using matchers' do
50
50
  expect(string).to have_css('#page')
51
51
  expect(string).not_to have_css('#does-not-exist')
52
52
  end
53
53
 
54
- it "allows using custom matchers" do
54
+ it 'allows using custom matchers' do
55
55
  Capybara.add_selector :lifeform do
56
56
  xpath { |name| ".//option[contains(.,'#{name}')]" }
57
57
  end
58
- expect(string).to have_selector(:id, "page")
58
+ expect(string).to have_selector(:id, 'page')
59
59
  expect(string).not_to have_selector(:id, 'does-not-exist')
60
- expect(string).to have_selector(:lifeform, "Monkey")
61
- expect(string).not_to have_selector(:lifeform, "Gorilla")
60
+ expect(string).to have_selector(:lifeform, 'Monkey')
61
+ expect(string).not_to have_selector(:lifeform, 'Gorilla')
62
62
  end
63
63
 
64
64
  it 'allows custom matcher using css' do
@@ -69,72 +69,72 @@ RSpec.describe Capybara do
69
69
  expect(string).not_to have_selector(:section, 'section_8')
70
70
  end
71
71
 
72
- it "allows using matchers with text option" do
72
+ it 'allows using matchers with text option' do
73
73
  expect(string).to have_css('h1', text: 'Totally awesome')
74
74
  expect(string).not_to have_css('h1', text: 'Not so awesome')
75
75
  end
76
76
 
77
- it "allows finding only visible nodes" do
77
+ it 'allows finding only visible nodes' do
78
78
  expect(string.all(:css, '#secret', visible: true)).to be_empty
79
79
  expect(string.all(:css, '#secret', visible: false).size).to eq(1)
80
80
  end
81
81
 
82
- it "allows finding elements and extracting text from them" do
82
+ it 'allows finding elements and extracting text from them' do
83
83
  expect(string.find('//h1').text).to eq('Totally awesome')
84
84
  end
85
85
 
86
- it "allows finding elements and extracting attributes from them" do
86
+ it 'allows finding elements and extracting attributes from them' do
87
87
  expect(string.find('//h1')[:data]).to eq('fantastic')
88
88
  end
89
89
 
90
- it "allows finding elements and extracting the tag name from them" do
90
+ it 'allows finding elements and extracting the tag name from them' do
91
91
  expect(string.find('//h1').tag_name).to eq('h1')
92
92
  end
93
93
 
94
- it "allows finding elements and extracting the path" do
94
+ it 'allows finding elements and extracting the path' do
95
95
  expect(string.find('//h1').path).to eq('/html/body/div/div[1]/h1')
96
96
  end
97
97
 
98
- it "allows finding elements and extracting the value" do
98
+ it 'allows finding elements and extracting the value' do
99
99
  expect(string.find('//div/input').value).to eq('bar')
100
100
  expect(string.find('//select').value).to eq('Capybara')
101
101
  end
102
102
 
103
- it "allows finding elements and checking if they are visible" do
103
+ it 'allows finding elements and checking if they are visible' do
104
104
  expect(string.find('//h1')).to be_visible
105
- expect(string.find(:css, "#secret", visible: false)).not_to be_visible
105
+ expect(string.find(:css, '#secret', visible: false)).not_to be_visible
106
106
  end
107
107
 
108
- it "allows finding elements and checking if they are disabled" do
108
+ it 'allows finding elements and checking if they are disabled' do
109
109
  expect(string.find('//form/input[@name="bleh"]')).to be_disabled
110
110
  expect(string.find('//form/input[@name="meh"]')).not_to be_disabled
111
111
  end
112
112
 
113
- describe "#title" do
114
- it "returns the page title" do
115
- expect(string.title).to eq("simple_node")
113
+ describe '#title' do
114
+ it 'returns the page title' do
115
+ expect(string.title).to eq('simple_node')
116
116
  end
117
117
  end
118
118
 
119
- describe "#has_title?" do
120
- it "returns whether the page has the given title" do
119
+ describe '#has_title?' do
120
+ it 'returns whether the page has the given title' do
121
121
  expect(string.has_title?('simple_node')).to be_truthy
122
122
  expect(string.has_title?('monkey')).to be_falsey
123
123
  end
124
124
 
125
- it "allows regexp matches" do
125
+ it 'allows regexp matches' do
126
126
  expect(string.has_title?(/s[a-z]+_node/)).to be_truthy
127
127
  expect(string.has_title?(/monkey/)).to be_falsey
128
128
  end
129
129
  end
130
130
 
131
131
  describe '#has_no_title?' do
132
- it "returns whether the page does not have the given title" do
132
+ it 'returns whether the page does not have the given title' do
133
133
  expect(string.has_no_title?('simple_node')).to be_falsey
134
134
  expect(string.has_no_title?('monkey')).to be_truthy
135
135
  end
136
136
 
137
- it "allows regexp matches" do
137
+ it 'allows regexp matches' do
138
138
  expect(string.has_no_title?(/s[a-z]+_node/)).to be_falsey
139
139
  expect(string.has_no_title?(/monkey/)).to be_truthy
140
140
  end
@@ -8,7 +8,7 @@ RSpec.describe Capybara do
8
8
  Capybara.default_max_wait_time = @previous_default_time
9
9
  end
10
10
 
11
- it "should be changeable" do
11
+ it 'should be changeable' do
12
12
  @previous_default_time = Capybara.default_max_wait_time
13
13
  Capybara.default_max_wait_time = 5
14
14
  expect(Capybara.default_max_wait_time).to eq(5)
@@ -16,18 +16,18 @@ RSpec.describe Capybara do
16
16
  end
17
17
 
18
18
  describe '.register_driver' do
19
- it "should add a new driver" do
19
+ it 'should add a new driver' do
20
20
  Capybara.register_driver :schmoo do |app|
21
21
  Capybara::RackTest::Driver.new(app)
22
22
  end
23
23
  session = Capybara::Session.new(:schmoo, TestApp)
24
24
  session.visit('/')
25
- expect(session.body).to include("Hello world!")
25
+ expect(session.body).to include('Hello world!')
26
26
  end
27
27
  end
28
28
 
29
29
  describe '.register_server' do
30
- it "should add a new server" do
30
+ it 'should add a new server' do
31
31
  Capybara.register_server :blob do |_app, _port, _host|
32
32
  # do nothing
33
33
  end
@@ -36,40 +36,40 @@ RSpec.describe Capybara do
36
36
  end
37
37
  end
38
38
 
39
- describe ".server" do
39
+ describe '.server' do
40
40
  after do
41
41
  Capybara.server = :default
42
42
  end
43
43
 
44
- it "should default to a proc that calls run_default_server" do
44
+ it 'should default to a proc that calls run_default_server' do
45
45
  mock_app = Object.new
46
46
  allow(Capybara).to receive(:run_default_server).and_return(true)
47
47
  Capybara.server.call(mock_app, 8000)
48
48
  expect(Capybara).to have_received(:run_default_server).with(mock_app, 8000)
49
49
  end
50
50
 
51
- it "should return a custom server proc" do
51
+ it 'should return a custom server proc' do
52
52
  server = ->(_app, _port) {}
53
53
  Capybara.register_server :custom, &server
54
54
  Capybara.server = :custom
55
55
  expect(Capybara.server).to eq(server)
56
56
  end
57
57
 
58
- it "should have :webrick registered" do
58
+ it 'should have :webrick registered' do
59
59
  expect(Capybara.servers[:webrick]).not_to be_nil
60
60
  end
61
61
 
62
- it "should have :puma registered" do
62
+ it 'should have :puma registered' do
63
63
  expect(Capybara.servers[:puma]).not_to be_nil
64
64
  end
65
65
  end
66
66
 
67
- describe "server=" do
67
+ describe 'server=' do
68
68
  after do
69
69
  Capybara.server = :default
70
70
  end
71
71
 
72
- it "accepts a proc" do
72
+ it 'accepts a proc' do
73
73
  server = ->(_app, _port) {}
74
74
  Capybara.server = server
75
75
  expect(Capybara.server).to eq server
@@ -81,15 +81,15 @@ RSpec.describe Capybara do
81
81
  Capybara.app_host = nil
82
82
  end
83
83
 
84
- it "should warn if not a valid URL" do
85
- expect { Capybara.app_host = "www.example.com" }.to raise_error(ArgumentError, /Capybara\.app_host should be set to a url/)
84
+ it 'should warn if not a valid URL' do
85
+ expect { Capybara.app_host = 'www.example.com' }.to raise_error(ArgumentError, /Capybara\.app_host should be set to a url/)
86
86
  end
87
87
 
88
- it "should not warn if a valid URL" do
89
- expect { Capybara.app_host = "http://www.example.com" }.not_to raise_error
88
+ it 'should not warn if a valid URL' do
89
+ expect { Capybara.app_host = 'http://www.example.com' }.not_to raise_error
90
90
  end
91
91
 
92
- it "should not warn if nil" do
92
+ it 'should not warn if nil' do
93
93
  expect { Capybara.app_host = nil }.not_to raise_error
94
94
  end
95
95
  end
@@ -101,12 +101,12 @@ RSpec.describe Capybara do
101
101
  Capybara.default_host = old_default
102
102
  end
103
103
 
104
- it "should raise if not a valid URL" do
105
- expect { Capybara.default_host = "www.example.com" }.to raise_error(ArgumentError, /Capybara\.default_host should be set to a url/)
104
+ it 'should raise if not a valid URL' do
105
+ expect { Capybara.default_host = 'www.example.com' }.to raise_error(ArgumentError, /Capybara\.default_host should be set to a url/)
106
106
  end
107
107
 
108
- it "should not warn if a valid URL" do
109
- expect { Capybara.default_host = "http://www.example.com" }.not_to raise_error
108
+ it 'should not warn if a valid URL' do
109
+ expect { Capybara.default_host = 'http://www.example.com' }.not_to raise_error
110
110
  end
111
111
  end
112
112
  end
@@ -7,30 +7,30 @@ RSpec.describe Capybara::Selector::CSS::Splitter do
7
7
  ::Capybara::Selector::CSS::Splitter.new
8
8
  end
9
9
 
10
- context "split not needed" do
11
- it "normal CSS selector" do
10
+ context 'split not needed' do
11
+ it 'normal CSS selector' do
12
12
  css = 'div[id="abc"]'
13
13
  expect(splitter.split(css)).to eq [css]
14
14
  end
15
15
 
16
- it "comma in strings" do
16
+ it 'comma in strings' do
17
17
  css = 'div[id="a,bc"]'
18
18
  expect(splitter.split(css)).to eq [css]
19
19
  end
20
20
 
21
- it "comma in pseudo-selector" do
21
+ it 'comma in pseudo-selector' do
22
22
  css = 'div.class1:not(.class1, .class2)'
23
23
  expect(splitter.split(css)).to eq [css]
24
24
  end
25
25
  end
26
26
 
27
- context "split needed" do
28
- it "root level comma" do
27
+ context 'split needed' do
28
+ it 'root level comma' do
29
29
  css = 'div.class1, span, p.class2'
30
30
  expect(splitter.split(css)).to eq ['div.class1', 'span', 'p.class2']
31
31
  end
32
32
 
33
- it "root level comma when quotes and pseudo selectors" do
33
+ it 'root level comma when quotes and pseudo selectors' do
34
34
  css = 'div.class1[id="abc\\"def,ghi"]:not(.class3, .class4), span[id=\'a"c\\\'de\'], section, #abc\\,def'
35
35
  expect(splitter.split(css)).to eq ['div.class1[id="abc\\"def,ghi"]:not(.class3, .class4)', 'span[id=\'a"c\\\'de\']', 'section', '#abc\\,def']
36
36
  end