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
@@ -5,48 +5,48 @@ Capybara::SpecHelper.spec '#assert_all_of_selectors' do
5
5
  @session.visit('/with_html')
6
6
  end
7
7
 
8
- it "should be true if the given selectors are on the page" do
9
- @session.assert_all_of_selectors(:css, "p a#foo", "h2#h2one", "h2#h2two")
8
+ it 'should be true if the given selectors are on the page' do
9
+ @session.assert_all_of_selectors(:css, 'p a#foo', 'h2#h2one', 'h2#h2two')
10
10
  end
11
11
 
12
- it "should be false if any of the given selectors are not on the page" do
13
- expect { @session.assert_all_of_selectors(:css, "p a#foo", "h2#h2three", "h2#h2one") }.to raise_error(Capybara::ElementNotFound)
12
+ it 'should be false if any of the given selectors are not on the page' do
13
+ expect { @session.assert_all_of_selectors(:css, 'p a#foo', 'h2#h2three', 'h2#h2one') }.to raise_error(Capybara::ElementNotFound)
14
14
  end
15
15
 
16
- it "should use default selector" do
16
+ it 'should use default selector' do
17
17
  Capybara.default_selector = :css
18
- expect { @session.assert_all_of_selectors("p a#foo", "h2#h2three", "h2#h2one") }.to raise_error(Capybara::ElementNotFound)
19
- @session.assert_all_of_selectors("p a#foo", "h2#h2two", "h2#h2one")
18
+ expect { @session.assert_all_of_selectors('p a#foo', 'h2#h2three', 'h2#h2one') }.to raise_error(Capybara::ElementNotFound)
19
+ @session.assert_all_of_selectors('p a#foo', 'h2#h2two', 'h2#h2one')
20
20
  end
21
21
 
22
- context "should respect scopes" do
23
- it "when used with `within`" do
22
+ context 'should respect scopes' do
23
+ it 'when used with `within`' do
24
24
  @session.within "//p[@id='first']" do
25
25
  @session.assert_all_of_selectors(".//a[@id='foo']")
26
26
  expect { @session.assert_all_of_selectors(".//a[@id='red']") }.to raise_error(Capybara::ElementNotFound)
27
27
  end
28
28
  end
29
29
 
30
- it "when called on elements" do
30
+ it 'when called on elements' do
31
31
  el = @session.find "//p[@id='first']"
32
32
  el.assert_all_of_selectors(".//a[@id='foo']")
33
33
  expect { el.assert_all_of_selectors(".//a[@id='red']") }.to raise_error(Capybara::ElementNotFound)
34
34
  end
35
35
  end
36
36
 
37
- context "with options" do
38
- it "should apply options to all locators" do
37
+ context 'with options' do
38
+ it 'should apply options to all locators' do
39
39
  @session.assert_all_of_selectors(:field, 'normal', 'additional_newline', type: :textarea)
40
40
  expect { @session.assert_all_of_selectors(:field, 'normal', 'test_field', 'additional_newline', type: :textarea) }.to raise_error(Capybara::ElementNotFound)
41
41
  end
42
42
  end
43
43
 
44
- context "with wait", requires: [:js] do
45
- it "should not raise error if all the elements appear before given wait duration" do
44
+ context 'with wait', requires: [:js] do
45
+ it 'should not raise error if all the elements appear before given wait duration' do
46
46
  Capybara.using_wait_time(0.1) do
47
47
  @session.visit('/with_js')
48
48
  @session.click_link('Click me')
49
- @session.assert_all_of_selectors(:css, "a#clickable", "a#has-been-clicked", '#drag', wait: 0.9)
49
+ @session.assert_all_of_selectors(:css, 'a#clickable', 'a#has-been-clicked', '#drag', wait: 1.5)
50
50
  end
51
51
  end
52
52
  end
@@ -57,55 +57,55 @@ Capybara::SpecHelper.spec '#assert_none_of_selectors' do
57
57
  @session.visit('/with_html')
58
58
  end
59
59
 
60
- it "should be false if any of the given locators are on the page" do
61
- expect { @session.assert_none_of_selectors(:xpath, "//p", "//a") }.to raise_error(Capybara::ElementNotFound)
62
- expect { @session.assert_none_of_selectors(:xpath, "//abbr", "//a") }.to raise_error(Capybara::ElementNotFound)
63
- expect { @session.assert_none_of_selectors(:css, "p a#foo") }.to raise_error(Capybara::ElementNotFound)
60
+ it 'should be false if any of the given locators are on the page' do
61
+ expect { @session.assert_none_of_selectors(:xpath, '//p', '//a') }.to raise_error(Capybara::ElementNotFound)
62
+ expect { @session.assert_none_of_selectors(:xpath, '//abbr', '//a') }.to raise_error(Capybara::ElementNotFound)
63
+ expect { @session.assert_none_of_selectors(:css, 'p a#foo') }.to raise_error(Capybara::ElementNotFound)
64
64
  end
65
65
 
66
- it "should be true if none of the given locators are on the page" do
67
- @session.assert_none_of_selectors(:xpath, "//abbr", "//td")
68
- @session.assert_none_of_selectors(:css, "p a#doesnotexist", "abbr")
66
+ it 'should be true if none of the given locators are on the page' do
67
+ @session.assert_none_of_selectors(:xpath, '//abbr', '//td')
68
+ @session.assert_none_of_selectors(:css, 'p a#doesnotexist', 'abbr')
69
69
  end
70
70
 
71
- it "should use default selector" do
71
+ it 'should use default selector' do
72
72
  Capybara.default_selector = :css
73
- @session.assert_none_of_selectors("p a#doesnotexist", "abbr")
74
- expect { @session.assert_none_of_selectors("abbr", "p a#foo") }.to raise_error(Capybara::ElementNotFound)
73
+ @session.assert_none_of_selectors('p a#doesnotexist', 'abbr')
74
+ expect { @session.assert_none_of_selectors('abbr', 'p a#foo') }.to raise_error(Capybara::ElementNotFound)
75
75
  end
76
76
 
77
- context "should respect scopes" do
78
- it "when used with `within`" do
77
+ context 'should respect scopes' do
78
+ it 'when used with `within`' do
79
79
  @session.within "//p[@id='first']" do
80
80
  expect { @session.assert_none_of_selectors(".//a[@id='foo']") }.to raise_error(Capybara::ElementNotFound)
81
81
  @session.assert_none_of_selectors(".//a[@id='red']")
82
82
  end
83
83
  end
84
84
 
85
- it "when called on an element" do
85
+ it 'when called on an element' do
86
86
  el = @session.find "//p[@id='first']"
87
87
  expect { el.assert_none_of_selectors(".//a[@id='foo']") }.to raise_error(Capybara::ElementNotFound)
88
88
  el.assert_none_of_selectors(".//a[@id='red']")
89
89
  end
90
90
  end
91
91
 
92
- context "with options" do
93
- it "should apply the options to all locators" do
94
- expect { @session.assert_none_of_selectors("//p//a", text: "Redirect") }.to raise_error(Capybara::ElementNotFound)
95
- @session.assert_none_of_selectors("//p", text: "Doesnotexist")
92
+ context 'with options' do
93
+ it 'should apply the options to all locators' do
94
+ expect { @session.assert_none_of_selectors('//p//a', text: 'Redirect') }.to raise_error(Capybara::ElementNotFound)
95
+ @session.assert_none_of_selectors('//p', text: 'Doesnotexist')
96
96
  end
97
97
 
98
- it "should discard all matches where the given regexp is matched" do
99
- expect { @session.assert_none_of_selectors("//p//a", text: /re[dab]i/i, count: 1) }.to raise_error(Capybara::ElementNotFound)
100
- @session.assert_none_of_selectors("//p//a", text: /Red$/)
98
+ it 'should discard all matches where the given regexp is matched' do
99
+ expect { @session.assert_none_of_selectors('//p//a', text: /re[dab]i/i, count: 1) }.to raise_error(Capybara::ElementNotFound)
100
+ @session.assert_none_of_selectors('//p//a', text: /Red$/)
101
101
  end
102
102
  end
103
103
 
104
- context "with wait", requires: [:js] do
105
- it "should not find elements if they appear after given wait duration" do
104
+ context 'with wait', requires: [:js] do
105
+ it 'should not find elements if they appear after given wait duration' do
106
106
  @session.visit('/with_js')
107
107
  @session.click_link('Click me')
108
- @session.assert_none_of_selectors(:css, "#new_field", "a#has-been-clicked", wait: 0.1)
108
+ @session.assert_none_of_selectors(:css, '#new_field', 'a#has-been-clicked', wait: 0.1)
109
109
  end
110
110
  end
111
111
  end
@@ -5,38 +5,38 @@ Capybara::SpecHelper.spec '#assert_current_path' do
5
5
  @session.visit('/with_js')
6
6
  end
7
7
 
8
- it "should not raise if the page has the given current path" do
8
+ it 'should not raise if the page has the given current path' do
9
9
  expect { @session.assert_current_path('/with_js') }.not_to raise_error
10
10
  end
11
11
 
12
- it "should allow regexp matches" do
12
+ it 'should allow regexp matches' do
13
13
  expect { @session.assert_current_path(/w[a-z]{3}_js/) }.not_to raise_error
14
14
  end
15
15
 
16
- it "should wait for current_path", requires: [:js] do
17
- @session.click_link("Change page")
18
- expect { @session.assert_current_path("/with_html") }.not_to raise_error
16
+ it 'should wait for current_path', requires: [:js] do
17
+ @session.click_link('Change page')
18
+ expect { @session.assert_current_path('/with_html') }.not_to raise_error
19
19
  end
20
20
 
21
- it "should raise if the page has not the given current_path" do
21
+ it 'should raise if the page has not the given current_path' do
22
22
  expect { @session.assert_current_path('/with_html') }.to raise_error(Capybara::ExpectationNotMet, 'expected "/with_js" to equal "/with_html"')
23
23
  end
24
24
 
25
- it "should check query options" do
25
+ it 'should check query options' do
26
26
  @session.visit('/with_js?test=test')
27
27
  expect { @session.assert_current_path('/with_js?test=test') }.not_to raise_error
28
28
  end
29
29
 
30
- it "should compare the full url" do
30
+ it 'should compare the full url' do
31
31
  expect { @session.assert_current_path(%r{\Ahttp://[^/]*/with_js\Z}, url: true) }.not_to raise_error
32
32
  end
33
33
 
34
- it "should ignore the query" do
34
+ it 'should ignore the query' do
35
35
  @session.visit('/with_js?test=test')
36
36
  expect { @session.assert_current_path('/with_js', ignore_query: true) }.not_to raise_error
37
37
  end
38
38
 
39
- it "should not cause an exception when current_url is nil" do
39
+ it 'should not cause an exception when current_url is nil' do
40
40
  allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
41
41
  expect { @session.assert_current_path(nil) }.not_to raise_error
42
42
  end
@@ -47,24 +47,24 @@ Capybara::SpecHelper.spec '#assert_no_current_path?' do
47
47
  @session.visit('/with_js')
48
48
  end
49
49
 
50
- it "should raise if the page has the given current_path" do
50
+ it 'should raise if the page has the given current_path' do
51
51
  expect { @session.assert_no_current_path('/with_js') }.to raise_error(Capybara::ExpectationNotMet)
52
52
  end
53
53
 
54
- it "should allow regexp matches" do
54
+ it 'should allow regexp matches' do
55
55
  expect { @session.assert_no_current_path(/monkey/) }.not_to raise_error
56
56
  end
57
57
 
58
- it "should wait for current_path to disappear", requires: [:js] do
59
- @session.click_link("Change page")
58
+ it 'should wait for current_path to disappear', requires: [:js] do
59
+ @session.click_link('Change page')
60
60
  expect { @session.assert_no_current_path('/with_js') }.not_to raise_error
61
61
  end
62
62
 
63
- it "should not raise if the page has not the given current_path" do
63
+ it 'should not raise if the page has not the given current_path' do
64
64
  expect { @session.assert_no_current_path('/with_html') }.not_to raise_error
65
65
  end
66
66
 
67
- it "should not cause an exception when current_url is nil" do
67
+ it 'should not cause an exception when current_url is nil' do
68
68
  allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
69
69
 
70
70
  expect { @session.assert_no_current_path('/with_html') }.not_to raise_error
@@ -5,75 +5,75 @@ Capybara::SpecHelper.spec '#assert_selector' do
5
5
  @session.visit('/with_html')
6
6
  end
7
7
 
8
- it "should be true if the given selector is on the page" do
9
- @session.assert_selector(:xpath, "//p")
10
- @session.assert_selector(:css, "p a#foo")
8
+ it 'should be true if the given selector is on the page' do
9
+ @session.assert_selector(:xpath, '//p')
10
+ @session.assert_selector(:css, 'p a#foo')
11
11
  @session.assert_selector("//p[contains(.,'est')]")
12
12
  end
13
13
 
14
- it "should be false if the given selector is not on the page" do
15
- expect { @session.assert_selector(:xpath, "//abbr") }.to raise_error(Capybara::ElementNotFound)
16
- expect { @session.assert_selector(:css, "p a#doesnotexist") }.to raise_error(Capybara::ElementNotFound)
14
+ it 'should be false if the given selector is not on the page' do
15
+ expect { @session.assert_selector(:xpath, '//abbr') }.to raise_error(Capybara::ElementNotFound)
16
+ expect { @session.assert_selector(:css, 'p a#doesnotexist') }.to raise_error(Capybara::ElementNotFound)
17
17
  expect { @session.assert_selector("//p[contains(.,'thisstringisnotonpage')]") }.to raise_error(Capybara::ElementNotFound)
18
18
  end
19
19
 
20
- it "should use default selector" do
20
+ it 'should use default selector' do
21
21
  Capybara.default_selector = :css
22
- expect { @session.assert_selector("p a#doesnotexist") }.to raise_error(Capybara::ElementNotFound)
23
- @session.assert_selector("p a#foo")
22
+ expect { @session.assert_selector('p a#doesnotexist') }.to raise_error(Capybara::ElementNotFound)
23
+ @session.assert_selector('p a#foo')
24
24
  end
25
25
 
26
- it "should respect scopes" do
26
+ it 'should respect scopes' do
27
27
  @session.within "//p[@id='first']" do
28
28
  @session.assert_selector(".//a[@id='foo']")
29
29
  expect { @session.assert_selector(".//a[@id='red']") }.to raise_error(Capybara::ElementNotFound)
30
30
  end
31
31
  end
32
32
 
33
- context "with count" do
34
- it "should be true if the content is on the page the given number of times" do
35
- @session.assert_selector("//p", count: 3)
33
+ context 'with count' do
34
+ it 'should be true if the content is on the page the given number of times' do
35
+ @session.assert_selector('//p', count: 3)
36
36
  @session.assert_selector("//p//a[@id='foo']", count: 1)
37
37
  @session.assert_selector("//p[contains(.,'est')]", count: 1)
38
38
  end
39
39
 
40
- it "should be false if the content is on the page the given number of times" do
41
- expect { @session.assert_selector("//p", count: 6) }.to raise_error(Capybara::ElementNotFound)
40
+ it 'should be false if the content is on the page the given number of times' do
41
+ expect { @session.assert_selector('//p', count: 6) }.to raise_error(Capybara::ElementNotFound)
42
42
  expect { @session.assert_selector("//p//a[@id='foo']", count: 2) }.to raise_error(Capybara::ElementNotFound)
43
43
  expect { @session.assert_selector("//p[contains(.,'est')]", count: 5) }.to raise_error(Capybara::ElementNotFound)
44
44
  end
45
45
 
46
46
  it "should be false if the content isn't on the page at all" do
47
- expect { @session.assert_selector("//abbr", count: 2) }.to raise_error(Capybara::ElementNotFound)
47
+ expect { @session.assert_selector('//abbr', count: 2) }.to raise_error(Capybara::ElementNotFound)
48
48
  expect { @session.assert_selector("//p//a[@id='doesnotexist']", count: 1) }.to raise_error(Capybara::ElementNotFound)
49
49
  end
50
50
  end
51
51
 
52
- context "with text" do
53
- it "should discard all matches where the given string is not contained" do
54
- @session.assert_selector("//p//a", text: "Redirect", count: 1)
55
- expect { @session.assert_selector("//p", text: "Doesnotexist") }.to raise_error(Capybara::ElementNotFound)
52
+ context 'with text' do
53
+ it 'should discard all matches where the given string is not contained' do
54
+ @session.assert_selector('//p//a', text: 'Redirect', count: 1)
55
+ expect { @session.assert_selector('//p', text: 'Doesnotexist') }.to raise_error(Capybara::ElementNotFound)
56
56
  end
57
57
 
58
- it "should discard all matches where the given regexp is not matched" do
59
- @session.assert_selector("//p//a", text: /re[dab]i/i, count: 1)
60
- expect { @session.assert_selector("//p//a", text: /Red$/) }.to raise_error(Capybara::ElementNotFound)
58
+ it 'should discard all matches where the given regexp is not matched' do
59
+ @session.assert_selector('//p//a', text: /re[dab]i/i, count: 1)
60
+ expect { @session.assert_selector('//p//a', text: /Red$/) }.to raise_error(Capybara::ElementNotFound)
61
61
  end
62
62
  end
63
63
 
64
- context "with wait", requires: [:js] do
65
- it "should find element if it appears before given wait duration" do
64
+ context 'with wait', requires: [:js] do
65
+ it 'should find element if it appears before given wait duration' do
66
66
  Capybara.using_wait_time(0.1) do
67
67
  @session.visit('/with_js')
68
68
  @session.click_link('Click me')
69
- @session.assert_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 2)
69
+ @session.assert_selector(:css, 'a#has-been-clicked', text: 'Has been clicked', wait: 2)
70
70
  end
71
71
  end
72
72
  end
73
73
  end
74
74
 
75
75
  Capybara::SpecHelper.spec '#refute_selector' do
76
- it "should be an alias of #assert_no_selector" do
76
+ it 'should be an alias of #assert_no_selector' do
77
77
  expect(Capybara::Node::Matchers.instance_method(:refute_selector)).to eq Capybara::Node::Matchers.instance_method(:assert_no_selector)
78
78
  end
79
79
  end
@@ -83,67 +83,67 @@ Capybara::SpecHelper.spec '#assert_no_selector' do
83
83
  @session.visit('/with_html')
84
84
  end
85
85
 
86
- it "should be false if the given selector is on the page" do
87
- expect { @session.assert_no_selector(:xpath, "//p") }.to raise_error(Capybara::ElementNotFound)
88
- expect { @session.assert_no_selector(:css, "p a#foo") }.to raise_error(Capybara::ElementNotFound)
86
+ it 'should be false if the given selector is on the page' do
87
+ expect { @session.assert_no_selector(:xpath, '//p') }.to raise_error(Capybara::ElementNotFound)
88
+ expect { @session.assert_no_selector(:css, 'p a#foo') }.to raise_error(Capybara::ElementNotFound)
89
89
  expect { @session.assert_no_selector("//p[contains(.,'est')]") }.to raise_error(Capybara::ElementNotFound)
90
90
  end
91
91
 
92
- it "should be true if the given selector is not on the page" do
93
- @session.assert_no_selector(:xpath, "//abbr")
94
- @session.assert_no_selector(:css, "p a#doesnotexist")
92
+ it 'should be true if the given selector is not on the page' do
93
+ @session.assert_no_selector(:xpath, '//abbr')
94
+ @session.assert_no_selector(:css, 'p a#doesnotexist')
95
95
  @session.assert_no_selector("//p[contains(.,'thisstringisnotonpage')]")
96
96
  end
97
97
 
98
- it "should use default selector" do
98
+ it 'should use default selector' do
99
99
  Capybara.default_selector = :css
100
- @session.assert_no_selector("p a#doesnotexist")
101
- expect { @session.assert_no_selector("p a#foo") }.to raise_error(Capybara::ElementNotFound)
100
+ @session.assert_no_selector('p a#doesnotexist')
101
+ expect { @session.assert_no_selector('p a#foo') }.to raise_error(Capybara::ElementNotFound)
102
102
  end
103
103
 
104
- it "should respect scopes" do
104
+ it 'should respect scopes' do
105
105
  @session.within "//p[@id='first']" do
106
106
  expect { @session.assert_no_selector(".//a[@id='foo']") }.to raise_error(Capybara::ElementNotFound)
107
107
  @session.assert_no_selector(".//a[@id='red']")
108
108
  end
109
109
  end
110
110
 
111
- context "with count" do
112
- it "should be false if the content is on the page the given number of times" do
113
- expect { @session.assert_no_selector("//p", count: 3) }.to raise_error(Capybara::ElementNotFound)
111
+ context 'with count' do
112
+ it 'should be false if the content is on the page the given number of times' do
113
+ expect { @session.assert_no_selector('//p', count: 3) }.to raise_error(Capybara::ElementNotFound)
114
114
  expect { @session.assert_no_selector("//p//a[@id='foo']", count: 1) }.to raise_error(Capybara::ElementNotFound)
115
115
  expect { @session.assert_no_selector("//p[contains(.,'est')]", count: 1) }.to raise_error(Capybara::ElementNotFound)
116
116
  end
117
117
 
118
- it "should be true if the content is on the page the wrong number of times" do
119
- @session.assert_no_selector("//p", count: 6)
118
+ it 'should be true if the content is on the page the wrong number of times' do
119
+ @session.assert_no_selector('//p', count: 6)
120
120
  @session.assert_no_selector("//p//a[@id='foo']", count: 2)
121
121
  @session.assert_no_selector("//p[contains(.,'est')]", count: 5)
122
122
  end
123
123
 
124
124
  it "should be true if the content isn't on the page at all" do
125
- @session.assert_no_selector("//abbr", count: 2)
125
+ @session.assert_no_selector('//abbr', count: 2)
126
126
  @session.assert_no_selector("//p//a[@id='doesnotexist']", count: 1)
127
127
  end
128
128
  end
129
129
 
130
- context "with text" do
131
- it "should discard all matches where the given string is contained" do
132
- expect { @session.assert_no_selector("//p//a", text: "Redirect", count: 1) }.to raise_error(Capybara::ElementNotFound)
133
- @session.assert_no_selector("//p", text: "Doesnotexist")
130
+ context 'with text' do
131
+ it 'should discard all matches where the given string is contained' do
132
+ expect { @session.assert_no_selector('//p//a', text: 'Redirect', count: 1) }.to raise_error(Capybara::ElementNotFound)
133
+ @session.assert_no_selector('//p', text: 'Doesnotexist')
134
134
  end
135
135
 
136
- it "should discard all matches where the given regexp is matched" do
137
- expect { @session.assert_no_selector("//p//a", text: /re[dab]i/i, count: 1) }.to raise_error(Capybara::ElementNotFound)
138
- @session.assert_no_selector("//p//a", text: /Red$/)
136
+ it 'should discard all matches where the given regexp is matched' do
137
+ expect { @session.assert_no_selector('//p//a', text: /re[dab]i/i, count: 1) }.to raise_error(Capybara::ElementNotFound)
138
+ @session.assert_no_selector('//p//a', text: /Red$/)
139
139
  end
140
140
  end
141
141
 
142
- context "with wait", requires: [:js] do
143
- it "should not find element if it appears after given wait duration" do
142
+ context 'with wait', requires: [:js] do
143
+ it 'should not find element if it appears after given wait duration' do
144
144
  @session.visit('/with_js')
145
145
  @session.click_link('Click me')
146
- @session.assert_no_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 0.1)
146
+ @session.assert_no_selector(:css, 'a#has-been-clicked', text: 'Has been clicked', wait: 0.1)
147
147
  end
148
148
  end
149
149
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Capybara::SpecHelper.spec '#assert_style', requires: [:css] do
4
- it "should not raise if the elements style contains the given properties" do
4
+ it 'should not raise if the elements style contains the given properties' do
5
5
  @session.visit('/with_html')
6
6
  expect do
7
7
  @session.find(:css, '#first').assert_style(display: 'block')
@@ -15,10 +15,10 @@ Capybara::SpecHelper.spec '#assert_style', requires: [:css] do
15
15
  end.to raise_error(Capybara::ExpectationNotMet, 'Expected node to have styles {"display"=>"inline"}. Actual styles were {"display"=>"block"}')
16
16
  end
17
17
 
18
- it "should wait for style", requires: %i[css js] do
18
+ it 'should wait for style', requires: %i[css js] do
19
19
  @session.visit('/with_js')
20
20
  el = @session.find(:css, '#change')
21
- @session.click_link("Change size")
21
+ @session.click_link('Change size')
22
22
  expect do
23
23
  el.assert_style({ 'font-size': '50px' }, wait: 3)
24
24
  end.not_to raise_error
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Capybara::SpecHelper.spec '#assert_text' do
4
- it "should be true if the given text is on the page" do
4
+ it 'should be true if the given text is on the page' do
5
5
  @session.visit('/with_html')
6
6
  expect(@session.assert_text('est')).to eq(true)
7
7
  expect(@session.assert_text('Lorem')).to eq(true)
@@ -10,14 +10,14 @@ Capybara::SpecHelper.spec '#assert_text' do
10
10
  expect(@session.assert_text('text with whitespace')).to eq(true)
11
11
  end
12
12
 
13
- it "should take scopes into account" do
13
+ it 'should take scopes into account' do
14
14
  @session.visit('/with_html')
15
15
  @session.within("//a[@title='awesome title']") do
16
16
  expect(@session.assert_text('labore')).to eq(true)
17
17
  end
18
18
  end
19
19
 
20
- it "should raise if scoped to an element which does not have the text" do
20
+ it 'should raise if scoped to an element which does not have the text' do
21
21
  @session.visit('/with_html')
22
22
  @session.within("//a[@title='awesome title']") do
23
23
  expect do
@@ -26,18 +26,18 @@ Capybara::SpecHelper.spec '#assert_text' do
26
26
  end
27
27
  end
28
28
 
29
- it "should be true if :all given and text is invisible." do
29
+ it 'should be true if :all given and text is invisible.' do
30
30
  @session.visit('/with_html')
31
31
  expect(@session.assert_text(:all, 'Some of this text is hidden!')).to eq(true)
32
32
  end
33
33
 
34
- it "should be true if `Capybara.ignore_hidden_elements = true` and text is invisible." do
34
+ it 'should be true if `Capybara.ignore_hidden_elements = true` and text is invisible.' do
35
35
  Capybara.ignore_hidden_elements = false
36
36
  @session.visit('/with_html')
37
37
  expect(@session.assert_text('Some of this text is hidden!')).to eq(true)
38
38
  end
39
39
 
40
- it "should raise error with a helpful message if the requested text is present but invisible" do
40
+ it 'should raise error with a helpful message if the requested text is present but invisible' do
41
41
  @session.visit('/with_html')
42
42
  el = @session.find(:css, '#hidden-text')
43
43
  expect do
@@ -45,14 +45,14 @@ Capybara::SpecHelper.spec '#assert_text' do
45
45
  end.to raise_error(Capybara::ExpectationNotMet, /it was found 1 time including non-visible text/)
46
46
  end
47
47
 
48
- it "should raise error with a helpful message if the requested text is present but with incorrect case" do
48
+ it 'should raise error with a helpful message if the requested text is present but with incorrect case' do
49
49
  @session.visit('/with_html')
50
50
  expect do
51
51
  @session.assert_text('Text With Whitespace')
52
52
  end.to raise_error(Capybara::ExpectationNotMet, /it was found 1 time using a case insensitive search/)
53
53
  end
54
54
 
55
- it "should raise error with helpful message if requested text is present but invisible and with incorrect case", requires: [:js] do
55
+ it 'should raise error with helpful message if requested text is present but invisible and with incorrect case', requires: [:js] do
56
56
  @session.visit('/with_html')
57
57
  el = @session.find(:css, '#uppercase')
58
58
  expect do
@@ -60,14 +60,14 @@ Capybara::SpecHelper.spec '#assert_text' do
60
60
  end.to raise_error(Capybara::ExpectationNotMet, /it was found 1 time using a case insensitive search and it was found 1 time including non-visible text/)
61
61
  end
62
62
 
63
- it "should raise the correct error if requested text is missing but contains regex special characters" do
63
+ it 'should raise the correct error if requested text is missing but contains regex special characters' do
64
64
  @session.visit('/with_html')
65
65
  expect do
66
66
  @session.assert_text('[]*.')
67
67
  end.to raise_error(Capybara::ExpectationNotMet, /expected to find text "\[\]\*\."/)
68
68
  end
69
69
 
70
- it "should be true if the text in the page matches given regexp" do
70
+ it 'should be true if the text in the page matches given regexp' do
71
71
  @session.visit('/with_html')
72
72
  expect(@session.assert_text(/Lorem/)).to eq(true)
73
73
  end
@@ -79,35 +79,36 @@ Capybara::SpecHelper.spec '#assert_text' do
79
79
  end.to raise_error(Capybara::ExpectationNotMet, %r{\Aexpected to find text matching /xxxxyzzz/ in "This is a test\\nHeader Class(.+)"\Z})
80
80
  end
81
81
 
82
- it "should escape any characters that would have special meaning in a regexp" do
82
+ it 'should escape any characters that would have special meaning in a regexp' do
83
83
  @session.visit('/with_html')
84
84
  expect do
85
85
  @session.assert_text('.orem')
86
86
  end.to raise_error(Capybara::ExpectationNotMet)
87
87
  end
88
88
 
89
- it "should wait for text to appear", requires: [:js] do
89
+ it 'should wait for text to appear', requires: [:js] do
90
+ Capybara.default_max_wait_time = 2
90
91
  @session.visit('/with_js')
91
92
  @session.click_link('Click me')
92
93
  expect(@session.assert_text('Has been clicked')).to eq(true)
93
94
  end
94
95
 
95
- context "with between" do
96
- it "should be true if the text occurs within the range given" do
96
+ context 'with between' do
97
+ it 'should be true if the text occurs within the range given' do
97
98
  @session.visit('/with_count')
98
99
  expect(@session.assert_text('count', between: 1..3)).to eq(true)
99
100
  end
100
101
 
101
- it "should be false if the text occurs more or fewer times than range" do
102
+ it 'should be false if the text occurs more or fewer times than range' do
102
103
  @session.visit('/with_html')
103
104
  expect do
104
105
  @session.find(:css, '.number').assert_text(/\d/, between: 0..1)
105
- end.to raise_error(Capybara::ExpectationNotMet, "expected to find text matching /\\d/ between 0 and 1 times but found 2 times in \"42\"")
106
+ end.to raise_error(Capybara::ExpectationNotMet, 'expected to find text matching /\\d/ between 0 and 1 times but found 2 times in "42"')
106
107
  end
107
108
  end
108
109
 
109
- context "with wait", requires: [:js] do
110
- it "should find element if it appears before given wait duration" do
110
+ context 'with wait', requires: [:js] do
111
+ it 'should find element if it appears before given wait duration' do
111
112
  Capybara.using_wait_time(0) do
112
113
  @session.visit('/with_js')
113
114
  @session.find(:css, '#reload-list').click
@@ -115,7 +116,7 @@ Capybara::SpecHelper.spec '#assert_text' do
115
116
  end
116
117
  end
117
118
 
118
- it "should raise error if it appears after given wait duration" do
119
+ it 'should raise error if it appears after given wait duration' do
119
120
  Capybara.using_wait_time(0) do
120
121
  @session.visit('/with_js')
121
122
  @session.find(:css, '#reload-list').click
@@ -169,26 +170,26 @@ Capybara::SpecHelper.spec '#assert_text' do
169
170
  end
170
171
 
171
172
  Capybara::SpecHelper.spec '#assert_no_text' do
172
- it "should raise error if the given text is on the page at least once" do
173
+ it 'should raise error if the given text is on the page at least once' do
173
174
  @session.visit('/with_html')
174
175
  expect do
175
176
  @session.assert_no_text('Lorem')
176
177
  end.to raise_error(Capybara::ExpectationNotMet, /\Aexpected not to find text "Lorem" in "This is a test.*"\z/)
177
178
  end
178
179
 
179
- it "should be true if scoped to an element which does not have the text" do
180
+ it 'should be true if scoped to an element which does not have the text' do
180
181
  @session.visit('/with_html')
181
182
  @session.within("//a[@title='awesome title']") do
182
183
  expect(@session.assert_no_text('monkey')).to eq(true)
183
184
  end
184
185
  end
185
186
 
186
- it "should be true if the given text is on the page but not visible" do
187
+ it 'should be true if the given text is on the page but not visible' do
187
188
  @session.visit('/with_html')
188
189
  expect(@session.assert_no_text('Inside element with hidden ancestor')).to eq(true)
189
190
  end
190
191
 
191
- it "should raise error if :all given and text is invisible." do
192
+ it 'should raise error if :all given and text is invisible.' do
192
193
  @session.visit('/with_html')
193
194
  el = @session.find(:css, '#hidden-text', visible: false)
194
195
  expect do
@@ -196,7 +197,7 @@ Capybara::SpecHelper.spec '#assert_no_text' do
196
197
  end.to raise_error(Capybara::ExpectationNotMet, 'expected not to find text "Some of this text is hidden!" in "Some of this text is hidden!"')
197
198
  end
198
199
 
199
- it "should raise error if :all given and text is invisible." do
200
+ it 'should raise error if :all given and text is invisible.' do
200
201
  @session.visit('/with_html')
201
202
  el = @session.find(:css, '#some-hidden-text', visible: false)
202
203
  expect do
@@ -209,22 +210,22 @@ Capybara::SpecHelper.spec '#assert_no_text' do
209
210
  @session.assert_no_text(/xxxxyzzz/)
210
211
  end
211
212
 
212
- context "with count" do
213
- it "should be true if the text occurs within the range given" do
213
+ context 'with count' do
214
+ it 'should be true if the text occurs within the range given' do
214
215
  @session.visit('/with_count')
215
216
  expect(@session.assert_text('count', count: 2)).to eq(true)
216
217
  end
217
218
 
218
- it "should be false if the text occurs more or fewer times than range" do
219
+ it 'should be false if the text occurs more or fewer times than range' do
219
220
  @session.visit('/with_html')
220
221
  expect do
221
222
  @session.find(:css, '.number').assert_text(/\d/, count: 1)
222
- end.to raise_error(Capybara::ExpectationNotMet, "expected to find text matching /\\d/ 1 time but found 2 times in \"42\"")
223
+ end.to raise_error(Capybara::ExpectationNotMet, 'expected to find text matching /\\d/ 1 time but found 2 times in "42"')
223
224
  end
224
225
  end
225
226
 
226
- context "with wait", requires: [:js] do
227
- it "should not find element if it appears after given wait duration" do
227
+ context 'with wait', requires: [:js] do
228
+ it 'should not find element if it appears after given wait duration' do
228
229
  @session.visit('/with_js')
229
230
  @session.click_link('Click me')
230
231
  @session.find(:css, '#reload-list').click