capybara 3.3.1 → 3.4.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 (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
@@ -2,10 +2,10 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe "capybara/rspec", type: :view do
6
- it "allows matchers to be used on strings" do
5
+ RSpec.describe 'capybara/rspec', type: :view do
6
+ it 'allows matchers to be used on strings' do
7
7
  html = %(<h1>Test header</h1>)
8
- expect(html).to have_css("h1", text: "Test header")
8
+ expect(html).to have_css('h1', text: 'Test header')
9
9
  end
10
10
 
11
11
  it "doesn't include RSpecMatcherProxies" do
@@ -3,22 +3,22 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe 'Capybara RSpec Matchers', type: :feature do
6
- context "after called on session" do
7
- it "HaveSelector should allow getting a description of the matcher" do
6
+ context 'after called on session' do
7
+ it 'HaveSelector should allow getting a description of the matcher' do
8
8
  visit('/with_html')
9
9
  matcher = have_selector(:css, 'h2.head', minimum: 3)
10
10
  expect(page).to matcher
11
11
  expect { matcher.description }.not_to raise_error
12
12
  end
13
13
 
14
- it "HaveText should allow getting a description" do
14
+ it 'HaveText should allow getting a description' do
15
15
  visit('/with_html')
16
- matcher = have_text("Lorem")
16
+ matcher = have_text('Lorem')
17
17
  expect(page).to matcher
18
18
  expect { matcher.description }.not_to raise_error
19
19
  end
20
20
 
21
- it "should produce the same error for .to have_no_xxx and .not_to have_xxx" do
21
+ it 'should produce the same error for .to have_no_xxx and .not_to have_xxx' do
22
22
  visit('/with_html')
23
23
  not_to_msg = error_msg_for { expect(page).not_to have_selector(:css, '#referrer') }
24
24
  have_no_msg = error_msg_for { expect(page).to have_no_selector(:css, '#referrer') }
@@ -30,8 +30,8 @@ RSpec.describe 'Capybara RSpec Matchers', type: :feature do
30
30
  end
31
31
  end
32
32
 
33
- context "after called on element" do
34
- it "HaveSelector should allow getting a description" do
33
+ context 'after called on element' do
34
+ it 'HaveSelector should allow getting a description' do
35
35
  visit('/with_html')
36
36
  el = find(:css, '#first')
37
37
  matcher = have_selector(:css, 'a#foo')
@@ -39,7 +39,7 @@ RSpec.describe 'Capybara RSpec Matchers', type: :feature do
39
39
  expect { matcher.description }.not_to raise_error
40
40
  end
41
41
 
42
- it "MatchSelector should allow getting a description" do
42
+ it 'MatchSelector should allow getting a description' do
43
43
  visit('/with_html')
44
44
  el = find(:css, '#first')
45
45
  matcher = match_selector(:css, '#first')
@@ -47,10 +47,10 @@ RSpec.describe 'Capybara RSpec Matchers', type: :feature do
47
47
  expect { matcher.description }.not_to raise_error
48
48
  end
49
49
 
50
- it "HaveText should allow getting a description" do
50
+ it 'HaveText should allow getting a description' do
51
51
  visit('/with_html')
52
52
  el = find(:css, '#first')
53
- matcher = have_text("Lorem")
53
+ matcher = have_text('Lorem')
54
54
  expect(el).to matcher
55
55
  expect { matcher.description }.not_to raise_error
56
56
  end
@@ -3,69 +3,69 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe 'capybara/rspec' do
6
- context "Feature", type: :feature do
7
- it "should include Capybara in rspec" do
6
+ context 'Feature', type: :feature do
7
+ it 'should include Capybara in rspec' do
8
8
  visit('/foo')
9
9
  expect(page.body).to include('Another World')
10
10
  end
11
11
 
12
- it "should include RSpec matcher proxies" do
12
+ it 'should include RSpec matcher proxies' do
13
13
  expect(self.class.ancestors).to include Capybara::RSpecMatcherProxies
14
14
  end
15
15
 
16
- context "resetting session" do
17
- it "sets a cookie in one example..." do
16
+ context 'resetting session' do
17
+ it 'sets a cookie in one example...' do
18
18
  visit('/set_cookie')
19
19
  expect(page.body).to include('Cookie set to test_cookie')
20
20
  end
21
21
 
22
- it "...then it is not available in the next" do
22
+ it '...then it is not available in the next' do
23
23
  visit('/get_cookie')
24
24
  expect(page.body).not_to include('test_cookie')
25
25
  end
26
26
  end
27
27
 
28
- context "setting the current driver" do
29
- it "sets the current driver in one example..." do
28
+ context 'setting the current driver' do
29
+ it 'sets the current driver in one example...' do
30
30
  Capybara.current_driver = :selenium
31
31
  end
32
32
 
33
- it "...then it has returned to the default in the next example" do
33
+ it '...then it has returned to the default in the next example' do
34
34
  expect(Capybara.current_driver).to eq(:rack_test)
35
35
  end
36
36
  end
37
37
 
38
- it "switches to the javascript driver when giving it as metadata", js: true do
38
+ it 'switches to the javascript driver when giving it as metadata', js: true do
39
39
  expect(Capybara.current_driver).to eq(Capybara.javascript_driver)
40
40
  end
41
41
 
42
- it "switches to the given driver when giving it as metadata", driver: :culerity do
42
+ it 'switches to the given driver when giving it as metadata', driver: :culerity do
43
43
  expect(Capybara.current_driver).to eq(:culerity)
44
44
  end
45
45
 
46
- context "#all" do
47
- it "allows access to the Capybara finder" do
46
+ context '#all' do
47
+ it 'allows access to the Capybara finder' do
48
48
  visit('/with_html')
49
49
  found = all(:css, 'h2') { |element| element[:class] == 'head' }
50
50
  expect(found.size).to eq(5)
51
51
  end
52
52
 
53
- it "allows access to the RSpec matcher" do
53
+ it 'allows access to the RSpec matcher' do
54
54
  visit('/with_html')
55
55
  strings = %w[test1 test2]
56
56
  expect(strings).to all(be_a(String))
57
57
  end
58
58
  end
59
59
 
60
- context "#within" do
61
- it "allows access to the Capybara scoper" do
60
+ context '#within' do
61
+ it 'allows access to the Capybara scoper' do
62
62
  visit('/with_html')
63
63
  expect do
64
- within(:css, "#does_not_exist") { click_link "Go to simple" }
64
+ within(:css, '#does_not_exist') { click_link 'Go to simple' }
65
65
  end.to raise_error(Capybara::ElementNotFound)
66
66
  end
67
67
 
68
- it "allows access to the RSpec matcher" do
68
+ it 'allows access to the RSpec matcher' do
69
69
  visit('/with_html')
70
70
  # This reads terribly, but must call #within
71
71
  expect(find(:css, 'span.number').text.to_i).to within(1).of(41)
@@ -74,7 +74,7 @@ RSpec.describe 'capybara/rspec' do
74
74
  end
75
75
 
76
76
  context 'Type: Other', type: :other do
77
- context "when RSpec::Matchers is included after Capybara::DSL" do
77
+ context 'when RSpec::Matchers is included after Capybara::DSL' do
78
78
  before do
79
79
  class DSLMatchersTest
80
80
  include Capybara::DSL
@@ -84,28 +84,28 @@ RSpec.describe 'capybara/rspec' do
84
84
  @test_class_instance = DSLMatchersTest.new
85
85
  end
86
86
 
87
- context "#all" do
88
- it "allows access to the Capybara finder" do
87
+ context '#all' do
88
+ it 'allows access to the Capybara finder' do
89
89
  @test_class_instance.visit('/with_html')
90
90
  expect(@test_class_instance.all(:css, 'h2.head').size).to eq(5)
91
91
  end
92
92
 
93
- it "allows access to the RSpec matcher" do
93
+ it 'allows access to the RSpec matcher' do
94
94
  @test_class_instance.visit('/with_html')
95
95
  strings = %w[test1 test2]
96
96
  expect(strings).to @test_class_instance.all(be_a(String))
97
97
  end
98
98
  end
99
99
 
100
- context "#within" do
101
- it "allows access to the Capybara scoper" do
100
+ context '#within' do
101
+ it 'allows access to the Capybara scoper' do
102
102
  @test_class_instance.visit('/with_html')
103
103
  expect do
104
- @test_class_instance.within(:css, "#does_not_exist") { @test_class_instance.click_link "Go to simple" }
104
+ @test_class_instance.within(:css, '#does_not_exist') { @test_class_instance.click_link 'Go to simple' }
105
105
  end.to raise_error(Capybara::ElementNotFound)
106
106
  end
107
107
 
108
- it "allows access to the RSpec matcher" do
108
+ it 'allows access to the RSpec matcher' do
109
109
  @test_class_instance.visit('/with_html')
110
110
  # This reads terribly, but must call #within
111
111
  expect(@test_class_instance.find(:css, 'span.number').text.to_i).to @test_class_instance.within(1).of(41)
@@ -113,14 +113,14 @@ RSpec.describe 'capybara/rspec' do
113
113
  end
114
114
  end
115
115
 
116
- it "should not include Capybara" do
116
+ it 'should not include Capybara' do
117
117
  expect { visit('/') }.to raise_error(NoMethodError)
118
118
  end
119
119
  end
120
120
  end
121
121
 
122
- feature "Feature DSL" do
123
- scenario "is pulled in" do
122
+ feature 'Feature DSL' do
123
+ scenario 'is pulled in' do
124
124
  visit('/foo')
125
125
  expect(page.body).to include('Another World')
126
126
  end
@@ -61,17 +61,17 @@ RSpec.describe Capybara do
61
61
  end
62
62
  end
63
63
 
64
- it "supports `filter` as an alias for `node_filter`" do
64
+ it 'supports `filter` as an alias for `node_filter`' do
65
65
  expect do
66
66
  Capybara.add_selector :filter_alias_selector do
67
- css { |_unused| "div" }
67
+ css { |_unused| 'div' }
68
68
  filter(:something) { |_node, _value| true }
69
69
  end
70
70
  end.not_to raise_error
71
71
  end
72
72
 
73
- describe "adding a selector" do
74
- it "can set default visiblity" do
73
+ describe 'adding a selector' do
74
+ it 'can set default visiblity' do
75
75
  Capybara.add_selector :hidden_field do
76
76
  visible :hidden
77
77
  css { |_sel| 'input[type="hidden"]' }
@@ -82,8 +82,8 @@ RSpec.describe Capybara do
82
82
  end
83
83
  end
84
84
 
85
- describe "modify_selector" do
86
- it "allows modifying a selector" do
85
+ describe 'modify_selector' do
86
+ it 'allows modifying a selector' do
87
87
  el = string.find(:custom_selector, 'a')
88
88
  expect(el.tag_name).to eq 'div'
89
89
  Capybara.modify_selector :custom_selector do
@@ -103,21 +103,21 @@ RSpec.describe Capybara do
103
103
  end
104
104
  end
105
105
 
106
- describe "builtin selectors" do
107
- context "when locator is nil" do
108
- it "devolves to just finding element types" do
106
+ describe 'builtin selectors' do
107
+ context 'when locator is nil' do
108
+ it 'devolves to just finding element types' do
109
109
  selectors = {
110
110
  field: ".//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]",
111
- fieldset: ".//fieldset",
112
- link: ".//a[./@href]",
111
+ fieldset: './/fieldset',
112
+ link: './/a[./@href]',
113
113
  link_or_button: ".//a[./@href] | .//input[./@type = 'submit' or ./@type = 'reset' or ./@type = 'image' or ./@type = 'button'] | .//button",
114
114
  fillable_field: ".//*[self::input | self::textarea][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'radio' or ./@type = 'checkbox' or ./@type = 'hidden' or ./@type = 'file')]",
115
115
  radio_button: ".//input[./@type = 'radio']",
116
116
  checkbox: ".//input[./@type = 'checkbox']",
117
- select: ".//select",
118
- option: ".//option",
117
+ select: './/select',
118
+ option: './/option',
119
119
  file_field: ".//input[./@type = 'file']",
120
- table: ".//table"
120
+ table: './/table'
121
121
  }
122
122
  selectors.each do |selector, xpath|
123
123
  results = string.all(selector, nil).to_a.map(&:native)
@@ -127,53 +127,53 @@ RSpec.describe Capybara do
127
127
  end
128
128
  end
129
129
 
130
- context "with :id option" do
131
- it "works with compound css selectors" do
132
- expect(string.all(:custom_css_selector, "div, h1", id: 'page').size).to eq 1
133
- expect(string.all(:custom_css_selector, "h1, div", id: 'page').size).to eq 1
130
+ context 'with :id option' do
131
+ it 'works with compound css selectors' do
132
+ expect(string.all(:custom_css_selector, 'div, h1', id: 'page').size).to eq 1
133
+ expect(string.all(:custom_css_selector, 'h1, div', id: 'page').size).to eq 1
134
134
  end
135
135
 
136
136
  it "works with 'special' characters" do
137
- expect(string.find(:custom_css_selector, "div", id: "#special")[:id]).to eq '#special'
138
- expect(string.find(:custom_css_selector, "input", id: "2checkbox")[:id]).to eq '2checkbox'
137
+ expect(string.find(:custom_css_selector, 'div', id: '#special')[:id]).to eq '#special'
138
+ expect(string.find(:custom_css_selector, 'input', id: '2checkbox')[:id]).to eq '2checkbox'
139
139
  end
140
140
 
141
- it "accepts XPath expression for xpath based selectors" do
141
+ it 'accepts XPath expression for xpath based selectors' do
142
142
  expect(string.find(:custom_xpath_selector, './/div', id: XPath.contains('peci'))[:id]).to eq '#special'
143
143
  expect(string.find(:custom_xpath_selector, './/input', id: XPath.ends_with('box'))[:id]).to eq '2checkbox'
144
144
  end
145
145
 
146
- it "errors XPath expression for CSS based selectors" do
147
- expect { string.find(:custom_css_selector, "div", id: XPath.contains('peci')) }
146
+ it 'errors XPath expression for CSS based selectors' do
147
+ expect { string.find(:custom_css_selector, 'div', id: XPath.contains('peci')) }
148
148
  .to raise_error(ArgumentError, /not supported/)
149
149
  end
150
150
  end
151
151
 
152
- context "with :class option" do
153
- it "works with compound css selectors" do
154
- expect(string.all(:custom_css_selector, "div, h1", class: 'a').size).to eq 2
155
- expect(string.all(:custom_css_selector, "h1, div", class: 'a').size).to eq 2
152
+ context 'with :class option' do
153
+ it 'works with compound css selectors' do
154
+ expect(string.all(:custom_css_selector, 'div, h1', class: 'a').size).to eq 2
155
+ expect(string.all(:custom_css_selector, 'h1, div', class: 'a').size).to eq 2
156
156
  end
157
157
 
158
- it "handles negated classes" do
159
- expect(string.all(:custom_css_selector, "div, p", class: ['b', '!c']).size).to eq 2
160
- expect(string.all(:custom_css_selector, "div, p", class: ['!c', '!d', 'b']).size).to eq 1
158
+ it 'handles negated classes' do
159
+ expect(string.all(:custom_css_selector, 'div, p', class: ['b', '!c']).size).to eq 2
160
+ expect(string.all(:custom_css_selector, 'div, p', class: ['!c', '!d', 'b']).size).to eq 1
161
161
  expect(string.all(:custom_xpath_selector, XPath.descendant(:div, :p), class: ['b', '!c']).size).to eq 2
162
162
  expect(string.all(:custom_xpath_selector, XPath.descendant(:div, :p), class: ['!c', '!d', 'b']).size).to eq 1
163
163
  end
164
164
 
165
165
  it "works with 'special' characters" do
166
- expect(string.find(:custom_css_selector, "input", class: ".special")[:id]).to eq 'file'
167
- expect(string.find(:custom_css_selector, "input", class: "2checkbox")[:id]).to eq '2checkbox'
166
+ expect(string.find(:custom_css_selector, 'input', class: '.special')[:id]).to eq 'file'
167
+ expect(string.find(:custom_css_selector, 'input', class: '2checkbox')[:id]).to eq '2checkbox'
168
168
  end
169
169
 
170
- it "accepts XPath expression for xpath based selectors" do
170
+ it 'accepts XPath expression for xpath based selectors' do
171
171
  expect(string.find(:custom_xpath_selector, './/div', class: XPath.contains('dom wor'))[:id]).to eq 'random_words'
172
172
  expect(string.find(:custom_xpath_selector, './/div', class: XPath.ends_with('words'))[:id]).to eq 'random_words'
173
173
  end
174
174
 
175
- it "errors XPath expression for CSS based selectors" do
176
- expect { string.find(:custom_css_selector, "div", class: XPath.contains('random')) }
175
+ it 'errors XPath expression for CSS based selectors' do
176
+ expect { string.find(:custom_css_selector, 'div', class: XPath.contains('random')) }
177
177
  .to raise_error(ArgumentError, /not supported/)
178
178
  end
179
179
  end
@@ -181,96 +181,96 @@ RSpec.describe Capybara do
181
181
  # :css, :xpath, :id, :field, :fieldset, :link, :button, :link_or_button, :fillable_field, :radio_button, :checkbox, :select,
182
182
  # :option, :file_field, :label, :table, :frame
183
183
 
184
- describe ":css selector" do
185
- it "finds by CSS locator" do
186
- expect(string.find(:css, "input#my_text_input")[:name]).to eq 'form[my_text_input]'
184
+ describe ':css selector' do
185
+ it 'finds by CSS locator' do
186
+ expect(string.find(:css, 'input#my_text_input')[:name]).to eq 'form[my_text_input]'
187
187
  end
188
188
  end
189
189
 
190
- describe ":xpath selector" do
191
- it "finds by XPath locator" do
190
+ describe ':xpath selector' do
191
+ it 'finds by XPath locator' do
192
192
  expect(string.find(:xpath, './/input[@id="my_text_input"]')[:name]).to eq 'form[my_text_input]'
193
193
  end
194
194
  end
195
195
 
196
- describe ":id selector" do
197
- it "finds by locator" do
198
- expect(string.find(:id, "my_text_input")[:name]).to eq 'form[my_text_input]'
196
+ describe ':id selector' do
197
+ it 'finds by locator' do
198
+ expect(string.find(:id, 'my_text_input')[:name]).to eq 'form[my_text_input]'
199
199
  end
200
200
  end
201
201
 
202
- describe ":field selector" do
203
- it "finds by locator" do
202
+ describe ':field selector' do
203
+ it 'finds by locator' do
204
204
  expect(string.find(:field, 'My Text Input')[:id]).to eq 'my_text_input'
205
205
  expect(string.find(:field, 'my_text_input')[:id]).to eq 'my_text_input'
206
206
  expect(string.find(:field, 'form[my_text_input]')[:id]).to eq 'my_text_input'
207
207
  end
208
208
 
209
- it "finds by id" do
209
+ it 'finds by id' do
210
210
  expect(string.find(:field, id: 'my_text_input')[:name]).to eq 'form[my_text_input]'
211
211
  end
212
212
 
213
- it "finds by name" do
213
+ it 'finds by name' do
214
214
  expect(string.find(:field, name: 'form[my_text_input]')[:id]).to eq 'my_text_input'
215
215
  end
216
216
 
217
- it "finds by placeholder" do
217
+ it 'finds by placeholder' do
218
218
  expect(string.find(:field, placeholder: 'my text')[:id]).to eq 'my_text_input'
219
219
  end
220
220
 
221
- it "finds by type" do
221
+ it 'finds by type' do
222
222
  expect(string.find(:field, type: 'file')[:id]).to eq 'file'
223
223
  expect(string.find(:field, type: 'select')[:id]).to eq 'select'
224
224
  end
225
225
  end
226
226
 
227
- describe ":option selector" do
228
- it "finds disabled options" do
227
+ describe ':option selector' do
228
+ it 'finds disabled options' do
229
229
  expect(string.find(:option, disabled: true).value).to eq 'b'
230
230
  end
231
231
 
232
- it "finds selected options" do
232
+ it 'finds selected options' do
233
233
  expect(string.find(:option, selected: true).value).to eq 'c'
234
234
  end
235
235
 
236
- it "finds not selected and not disabled options" do
236
+ it 'finds not selected and not disabled options' do
237
237
  expect(string.find(:option, disabled: false, selected: false).value).to eq 'a'
238
238
  end
239
239
  end
240
240
 
241
- describe ":button selector" do
242
- it "finds by value" do
241
+ describe ':button selector' do
242
+ it 'finds by value' do
243
243
  expect(string.find(:button, 'click me').value).to eq 'click me'
244
244
  end
245
245
 
246
- it "finds by title" do
246
+ it 'finds by title' do
247
247
  expect(string.find(:button, 'submit button').value).to eq 'click me'
248
248
  end
249
249
 
250
- it "includes non-matching parameters in failure message" do
250
+ it 'includes non-matching parameters in failure message' do
251
251
  expect { string.find(:button, 'click me', title: 'click me') }.to raise_error(/with title click me/)
252
252
  end
253
253
  end
254
254
 
255
- describe ":element selector" do
256
- it "finds by any attributes" do
255
+ describe ':element selector' do
256
+ it 'finds by any attributes' do
257
257
  expect(string.find(:element, 'input', type: 'submit').value).to eq 'click me'
258
258
  end
259
259
 
260
- it "still works with system keys" do
260
+ it 'still works with system keys' do
261
261
  expect { string.all(:element, 'input', type: 'submit', count: 1) }.not_to raise_error
262
262
  end
263
263
 
264
- it "includes wildcarded keys in description" do
264
+ it 'includes wildcarded keys in description' do
265
265
  expect { string.find(:element, 'input', not_there: 'bad', count: 1) }
266
266
  .to(raise_error do |e|
267
267
  expect(e).to be_a(Capybara::ElementNotFound)
268
- expect(e.message).to include "not_there => bad"
269
- expect(e.message).not_to include "count 1"
268
+ expect(e.message).to include 'not_there => bad'
269
+ expect(e.message).not_to include 'count 1'
270
270
  end)
271
271
  end
272
272
 
273
- it "accepts XPath::Expression" do
273
+ it 'accepts XPath::Expression' do
274
274
  expect(string.find(:element, 'input', type: XPath.starts_with('subm')).value).to eq 'click me'
275
275
  expect(string.find(:element, 'input', type: XPath.ends_with('ext'))[:type]).to eq 'text'
276
276
  expect(string.find(:element, 'input', type: XPath.contains('ckb'))[:type]).to eq 'checkbox'