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
@@ -5,37 +5,37 @@ Capybara::SpecHelper.spec '#has_button?' do
5
5
  @session.visit('/form')
6
6
  end
7
7
 
8
- it "should be true if the given button is on the page" do
8
+ it 'should be true if the given button is on the page' do
9
9
  expect(@session).to have_button('med')
10
10
  expect(@session).to have_button('crap321')
11
11
  expect(@session).to have_button(:crap321)
12
12
  end
13
13
 
14
- it "should be true for disabled buttons if disabled: true" do
14
+ it 'should be true for disabled buttons if disabled: true' do
15
15
  expect(@session).to have_button('Disabled button', disabled: true)
16
16
  end
17
17
 
18
- it "should be false if the given button is not on the page" do
18
+ it 'should be false if the given button is not on the page' do
19
19
  expect(@session).not_to have_button('monkey')
20
20
  end
21
21
 
22
- it "should be false for disabled buttons by default" do
22
+ it 'should be false for disabled buttons by default' do
23
23
  expect(@session).not_to have_button('Disabled button')
24
24
  end
25
25
 
26
- it "should be false for disabled buttons if disabled: false" do
26
+ it 'should be false for disabled buttons if disabled: false' do
27
27
  expect(@session).not_to have_button('Disabled button', disabled: false)
28
28
  end
29
29
 
30
- it "should be true for disabled buttons if disabled: :all" do
30
+ it 'should be true for disabled buttons if disabled: :all' do
31
31
  expect(@session).to have_button('Disabled button', disabled: :all)
32
32
  end
33
33
 
34
- it "should be true for enabled buttons if disabled: :all" do
34
+ it 'should be true for enabled buttons if disabled: :all' do
35
35
  expect(@session).to have_button('med', disabled: :all)
36
36
  end
37
37
 
38
- it "can verify button type" do
38
+ it 'can verify button type' do
39
39
  expect(@session).to have_button('awe123', type: 'submit')
40
40
  expect(@session).not_to have_button('awe123', type: 'reset')
41
41
  end
@@ -46,24 +46,24 @@ Capybara::SpecHelper.spec '#has_no_button?' do
46
46
  @session.visit('/form')
47
47
  end
48
48
 
49
- it "should be true if the given button is on the page" do
49
+ it 'should be true if the given button is on the page' do
50
50
  expect(@session).not_to have_no_button('med')
51
51
  expect(@session).not_to have_no_button('crap321')
52
52
  end
53
53
 
54
- it "should be true for disabled buttons if disabled: true" do
54
+ it 'should be true for disabled buttons if disabled: true' do
55
55
  expect(@session).not_to have_no_button('Disabled button', disabled: true)
56
56
  end
57
57
 
58
- it "should be false if the given button is not on the page" do
58
+ it 'should be false if the given button is not on the page' do
59
59
  expect(@session).to have_no_button('monkey')
60
60
  end
61
61
 
62
- it "should be false for disabled buttons by default" do
62
+ it 'should be false for disabled buttons by default' do
63
63
  expect(@session).to have_no_button('Disabled button')
64
64
  end
65
65
 
66
- it "should be false for disabled buttons if disabled: false" do
66
+ it 'should be false for disabled buttons if disabled: false' do
67
67
  expect(@session).to have_no_button('Disabled button', disabled: false)
68
68
  end
69
69
  end
@@ -5,116 +5,117 @@ Capybara::SpecHelper.spec '#has_css?' 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
- expect(@session).to have_css("p")
10
- expect(@session).to have_css("p a#foo")
8
+ it 'should be true if the given selector is on the page' do
9
+ expect(@session).to have_css('p')
10
+ expect(@session).to have_css('p a#foo')
11
11
  end
12
12
 
13
- it "should be false if the given selector is not on the page" do
14
- expect(@session).not_to have_css("abbr")
15
- expect(@session).not_to have_css("p a#doesnotexist")
16
- expect(@session).not_to have_css("p.nosuchclass")
13
+ it 'should be false if the given selector is not on the page' do
14
+ expect(@session).not_to have_css('abbr')
15
+ expect(@session).not_to have_css('p a#doesnotexist')
16
+ expect(@session).not_to have_css('p.nosuchclass')
17
17
  end
18
18
 
19
- it "should respect scopes" do
19
+ it 'should respect scopes' do
20
20
  @session.within "//p[@id='first']" do
21
- expect(@session).to have_css("a#foo")
22
- expect(@session).not_to have_css("a#red")
21
+ expect(@session).to have_css('a#foo')
22
+ expect(@session).not_to have_css('a#red')
23
23
  end
24
24
  end
25
25
 
26
- it "should wait for content to appear", requires: [:js] do
26
+ it 'should wait for content to appear', requires: [:js] do
27
+ Capybara.default_max_wait_time = 2
27
28
  @session.visit('/with_js')
28
29
  @session.click_link('Click me')
29
30
  expect(@session).to have_css("input[type='submit'][value='New Here']")
30
31
  end
31
32
 
32
- context "with between" do
33
- it "should be true if the content occurs within the range given" do
34
- expect(@session).to have_css("p", between: 1..4)
35
- expect(@session).to have_css("p a#foo", between: 1..3)
36
- expect(@session).to have_css("p a.doesnotexist", between: 0..8)
33
+ context 'with between' do
34
+ it 'should be true if the content occurs within the range given' do
35
+ expect(@session).to have_css('p', between: 1..4)
36
+ expect(@session).to have_css('p a#foo', between: 1..3)
37
+ expect(@session).to have_css('p a.doesnotexist', between: 0..8)
37
38
  end
38
39
 
39
- it "should be false if the content occurs more or fewer times than range" do
40
- expect(@session).not_to have_css("p", between: 6..11)
41
- expect(@session).not_to have_css("p a#foo", between: 4..7)
42
- expect(@session).not_to have_css("p a.doesnotexist", between: 3..8)
40
+ it 'should be false if the content occurs more or fewer times than range' do
41
+ expect(@session).not_to have_css('p', between: 6..11)
42
+ expect(@session).not_to have_css('p a#foo', between: 4..7)
43
+ expect(@session).not_to have_css('p a.doesnotexist', between: 3..8)
43
44
  end
44
45
  end
45
46
 
46
- context "with count" do
47
- it "should be true if the content occurs the given number of times" do
48
- expect(@session).to have_css("p", count: 3)
49
- expect(@session).to have_css("p a#foo", count: 1)
50
- expect(@session).to have_css("p a.doesnotexist", count: 0)
47
+ context 'with count' do
48
+ it 'should be true if the content occurs the given number of times' do
49
+ expect(@session).to have_css('p', count: 3)
50
+ expect(@session).to have_css('p a#foo', count: 1)
51
+ expect(@session).to have_css('p a.doesnotexist', count: 0)
51
52
  end
52
53
 
53
- it "should be false if the content occurs a different number of times than the given" do
54
- expect(@session).not_to have_css("p", count: 6)
55
- expect(@session).not_to have_css("p a#foo", count: 2)
56
- expect(@session).not_to have_css("p a.doesnotexist", count: 1)
54
+ it 'should be false if the content occurs a different number of times than the given' do
55
+ expect(@session).not_to have_css('p', count: 6)
56
+ expect(@session).not_to have_css('p a#foo', count: 2)
57
+ expect(@session).not_to have_css('p a.doesnotexist', count: 1)
57
58
  end
58
59
 
59
- it "should coerce count to an integer" do
60
- expect(@session).to have_css("p", count: "3")
61
- expect(@session).to have_css("p a#foo", count: "1")
60
+ it 'should coerce count to an integer' do
61
+ expect(@session).to have_css('p', count: '3')
62
+ expect(@session).to have_css('p a#foo', count: '1')
62
63
  end
63
64
  end
64
65
 
65
- context "with maximum" do
66
- it "should be true when content occurs same or fewer times than given" do
67
- expect(@session).to have_css("h2.head", maximum: 5) # edge case
68
- expect(@session).to have_css("h2", maximum: 10)
69
- expect(@session).to have_css("p a.doesnotexist", maximum: 1)
70
- expect(@session).to have_css("p a.doesnotexist", maximum: 0)
66
+ context 'with maximum' do
67
+ it 'should be true when content occurs same or fewer times than given' do
68
+ expect(@session).to have_css('h2.head', maximum: 5) # edge case
69
+ expect(@session).to have_css('h2', maximum: 10)
70
+ expect(@session).to have_css('p a.doesnotexist', maximum: 1)
71
+ expect(@session).to have_css('p a.doesnotexist', maximum: 0)
71
72
  end
72
73
 
73
- it "should be false when content occurs more times than given" do
74
- expect(@session).not_to have_css("h2.head", maximum: 4) # edge case
75
- expect(@session).not_to have_css("h2", maximum: 3)
76
- expect(@session).not_to have_css("p", maximum: 1)
74
+ it 'should be false when content occurs more times than given' do
75
+ expect(@session).not_to have_css('h2.head', maximum: 4) # edge case
76
+ expect(@session).not_to have_css('h2', maximum: 3)
77
+ expect(@session).not_to have_css('p', maximum: 1)
77
78
  end
78
79
 
79
- it "should coerce maximum to an integer" do
80
- expect(@session).to have_css("h2.head", maximum: "5") # edge case
81
- expect(@session).to have_css("h2", maximum: "10")
80
+ it 'should coerce maximum to an integer' do
81
+ expect(@session).to have_css('h2.head', maximum: '5') # edge case
82
+ expect(@session).to have_css('h2', maximum: '10')
82
83
  end
83
84
  end
84
85
 
85
- context "with minimum" do
86
- it "should be true when content occurs same or more times than given" do
87
- expect(@session).to have_css("h2.head", minimum: 5) # edge case
88
- expect(@session).to have_css("h2", minimum: 3)
89
- expect(@session).to have_css("p a.doesnotexist", minimum: 0)
86
+ context 'with minimum' do
87
+ it 'should be true when content occurs same or more times than given' do
88
+ expect(@session).to have_css('h2.head', minimum: 5) # edge case
89
+ expect(@session).to have_css('h2', minimum: 3)
90
+ expect(@session).to have_css('p a.doesnotexist', minimum: 0)
90
91
  end
91
92
 
92
- it "should be false when content occurs fewer times than given" do
93
- expect(@session).not_to have_css("h2.head", minimum: 6) # edge case
94
- expect(@session).not_to have_css("h2", minimum: 8)
95
- expect(@session).not_to have_css("p", minimum: 10)
96
- expect(@session).not_to have_css("p a.doesnotexist", minimum: 1)
93
+ it 'should be false when content occurs fewer times than given' do
94
+ expect(@session).not_to have_css('h2.head', minimum: 6) # edge case
95
+ expect(@session).not_to have_css('h2', minimum: 8)
96
+ expect(@session).not_to have_css('p', minimum: 10)
97
+ expect(@session).not_to have_css('p a.doesnotexist', minimum: 1)
97
98
  end
98
99
 
99
- it "should coerce minimum to an integer" do
100
- expect(@session).to have_css("h2.head", minimum: "5") # edge case
101
- expect(@session).to have_css("h2", minimum: "3")
100
+ it 'should coerce minimum to an integer' do
101
+ expect(@session).to have_css('h2.head', minimum: '5') # edge case
102
+ expect(@session).to have_css('h2', minimum: '3')
102
103
  end
103
104
  end
104
105
 
105
- context "with text" do
106
- it "should discard all matches where the given string is not contained" do
107
- expect(@session).to have_css("p a", text: "Redirect", count: 1)
108
- expect(@session).not_to have_css("p a", text: "Doesnotexist")
106
+ context 'with text' do
107
+ it 'should discard all matches where the given string is not contained' do
108
+ expect(@session).to have_css('p a', text: 'Redirect', count: 1)
109
+ expect(@session).not_to have_css('p a', text: 'Doesnotexist')
109
110
  end
110
111
 
111
- it "should discard all matches where the given regexp is not matched" do
112
- expect(@session).to have_css("p a", text: /re[dab]i/i, count: 1)
113
- expect(@session).not_to have_css("p a", text: /Red$/)
112
+ it 'should discard all matches where the given regexp is not matched' do
113
+ expect(@session).to have_css('p a', text: /re[dab]i/i, count: 1)
114
+ expect(@session).not_to have_css('p a', text: /Red$/)
114
115
  end
115
116
  end
116
117
 
117
- it "should allow escapes in the CSS selector" do
118
+ it 'should allow escapes in the CSS selector' do
118
119
  expect(@session).to have_css('p[data-random="abc\\\\def"]')
119
120
  expect(@session).to have_css("p[data-random='#{Capybara::Selector::CSS.escape('abc\def')}']")
120
121
  end
@@ -125,111 +126,112 @@ Capybara::SpecHelper.spec '#has_no_css?' do
125
126
  @session.visit('/with_html')
126
127
  end
127
128
 
128
- it "should be false if the given selector is on the page" do
129
- expect(@session).not_to have_no_css("p")
130
- expect(@session).not_to have_no_css("p a#foo")
129
+ it 'should be false if the given selector is on the page' do
130
+ expect(@session).not_to have_no_css('p')
131
+ expect(@session).not_to have_no_css('p a#foo')
131
132
  end
132
133
 
133
- it "should be true if the given selector is not on the page" do
134
- expect(@session).to have_no_css("abbr")
135
- expect(@session).to have_no_css("p a#doesnotexist")
136
- expect(@session).to have_no_css("p.nosuchclass")
134
+ it 'should be true if the given selector is not on the page' do
135
+ expect(@session).to have_no_css('abbr')
136
+ expect(@session).to have_no_css('p a#doesnotexist')
137
+ expect(@session).to have_no_css('p.nosuchclass')
137
138
  end
138
139
 
139
- it "should respect scopes" do
140
+ it 'should respect scopes' do
140
141
  @session.within "//p[@id='first']" do
141
- expect(@session).not_to have_no_css("a#foo")
142
- expect(@session).to have_no_css("a#red")
142
+ expect(@session).not_to have_no_css('a#foo')
143
+ expect(@session).to have_no_css('a#red')
143
144
  end
144
145
  end
145
146
 
146
- it "should wait for content to disappear", requires: [:js] do
147
+ it 'should wait for content to disappear', requires: [:js] do
148
+ Capybara.default_max_wait_time = 2
147
149
  @session.visit('/with_js')
148
150
  @session.click_link('Click me')
149
- expect(@session).to have_no_css("p#change")
151
+ expect(@session).to have_no_css('p#change')
150
152
  end
151
153
 
152
- context "with between" do
153
- it "should be false if the content occurs within the range given" do
154
- expect(@session).not_to have_no_css("p", between: 1..4)
155
- expect(@session).not_to have_no_css("p a#foo", between: 1..3)
156
- expect(@session).not_to have_no_css("p a.doesnotexist", between: 0..2)
154
+ context 'with between' do
155
+ it 'should be false if the content occurs within the range given' do
156
+ expect(@session).not_to have_no_css('p', between: 1..4)
157
+ expect(@session).not_to have_no_css('p a#foo', between: 1..3)
158
+ expect(@session).not_to have_no_css('p a.doesnotexist', between: 0..2)
157
159
  end
158
160
 
159
- it "should be true if the content occurs more or fewer times than range" do
160
- expect(@session).to have_no_css("p", between: 6..11)
161
- expect(@session).to have_no_css("p a#foo", between: 4..7)
162
- expect(@session).to have_no_css("p a.doesnotexist", between: 3..8)
161
+ it 'should be true if the content occurs more or fewer times than range' do
162
+ expect(@session).to have_no_css('p', between: 6..11)
163
+ expect(@session).to have_no_css('p a#foo', between: 4..7)
164
+ expect(@session).to have_no_css('p a.doesnotexist', between: 3..8)
163
165
  end
164
166
  end
165
167
 
166
- context "with count" do
167
- it "should be false if the content is on the page the given number of times" do
168
- expect(@session).not_to have_no_css("p", count: 3)
169
- expect(@session).not_to have_no_css("p a#foo", count: 1)
170
- expect(@session).not_to have_no_css("p a.doesnotexist", count: 0)
168
+ context 'with count' do
169
+ it 'should be false if the content is on the page the given number of times' do
170
+ expect(@session).not_to have_no_css('p', count: 3)
171
+ expect(@session).not_to have_no_css('p a#foo', count: 1)
172
+ expect(@session).not_to have_no_css('p a.doesnotexist', count: 0)
171
173
  end
172
174
 
173
- it "should be true if the content is on the page the given number of times" do
174
- expect(@session).to have_no_css("p", count: 6)
175
- expect(@session).to have_no_css("p a#foo", count: 2)
176
- expect(@session).to have_no_css("p a.doesnotexist", count: 1)
175
+ it 'should be true if the content is on the page the given number of times' do
176
+ expect(@session).to have_no_css('p', count: 6)
177
+ expect(@session).to have_no_css('p a#foo', count: 2)
178
+ expect(@session).to have_no_css('p a.doesnotexist', count: 1)
177
179
  end
178
180
 
179
- it "should coerce count to an integer" do
180
- expect(@session).not_to have_no_css("p", count: "3")
181
- expect(@session).not_to have_no_css("p a#foo", count: "1")
181
+ it 'should coerce count to an integer' do
182
+ expect(@session).not_to have_no_css('p', count: '3')
183
+ expect(@session).not_to have_no_css('p a#foo', count: '1')
182
184
  end
183
185
  end
184
186
 
185
- context "with maximum" do
186
- it "should be false when content occurs same or fewer times than given" do
187
- expect(@session).not_to have_no_css("h2.head", maximum: 5) # edge case
188
- expect(@session).not_to have_no_css("h2", maximum: 10)
189
- expect(@session).not_to have_no_css("p a.doesnotexist", maximum: 0)
187
+ context 'with maximum' do
188
+ it 'should be false when content occurs same or fewer times than given' do
189
+ expect(@session).not_to have_no_css('h2.head', maximum: 5) # edge case
190
+ expect(@session).not_to have_no_css('h2', maximum: 10)
191
+ expect(@session).not_to have_no_css('p a.doesnotexist', maximum: 0)
190
192
  end
191
193
 
192
- it "should be true when content occurs more times than given" do
193
- expect(@session).to have_no_css("h2.head", maximum: 4) # edge case
194
- expect(@session).to have_no_css("h2", maximum: 3)
195
- expect(@session).to have_no_css("p", maximum: 1)
194
+ it 'should be true when content occurs more times than given' do
195
+ expect(@session).to have_no_css('h2.head', maximum: 4) # edge case
196
+ expect(@session).to have_no_css('h2', maximum: 3)
197
+ expect(@session).to have_no_css('p', maximum: 1)
196
198
  end
197
199
 
198
- it "should coerce maximum to an integer" do
199
- expect(@session).not_to have_no_css("h2.head", maximum: "5") # edge case
200
- expect(@session).not_to have_no_css("h2", maximum: "10")
200
+ it 'should coerce maximum to an integer' do
201
+ expect(@session).not_to have_no_css('h2.head', maximum: '5') # edge case
202
+ expect(@session).not_to have_no_css('h2', maximum: '10')
201
203
  end
202
204
  end
203
205
 
204
- context "with minimum" do
205
- it "should be false when content occurs same or more times than given" do
206
- expect(@session).not_to have_no_css("h2.head", minimum: 5) # edge case
207
- expect(@session).not_to have_no_css("h2", minimum: 3)
208
- expect(@session).not_to have_no_css("p a.doesnotexist", minimum: 0)
206
+ context 'with minimum' do
207
+ it 'should be false when content occurs same or more times than given' do
208
+ expect(@session).not_to have_no_css('h2.head', minimum: 5) # edge case
209
+ expect(@session).not_to have_no_css('h2', minimum: 3)
210
+ expect(@session).not_to have_no_css('p a.doesnotexist', minimum: 0)
209
211
  end
210
212
 
211
- it "should be true when content occurs fewer times than given" do
212
- expect(@session).to have_no_css("h2.head", minimum: 6) # edge case
213
- expect(@session).to have_no_css("h2", minimum: 8)
214
- expect(@session).to have_no_css("p", minimum: 15)
215
- expect(@session).to have_no_css("p a.doesnotexist", minimum: 1)
213
+ it 'should be true when content occurs fewer times than given' do
214
+ expect(@session).to have_no_css('h2.head', minimum: 6) # edge case
215
+ expect(@session).to have_no_css('h2', minimum: 8)
216
+ expect(@session).to have_no_css('p', minimum: 15)
217
+ expect(@session).to have_no_css('p a.doesnotexist', minimum: 1)
216
218
  end
217
219
 
218
- it "should coerce minimum to an integer" do
219
- expect(@session).not_to have_no_css("h2.head", minimum: "4") # edge case
220
- expect(@session).not_to have_no_css("h2", minimum: "3")
220
+ it 'should coerce minimum to an integer' do
221
+ expect(@session).not_to have_no_css('h2.head', minimum: '4') # edge case
222
+ expect(@session).not_to have_no_css('h2', minimum: '3')
221
223
  end
222
224
  end
223
225
 
224
- context "with text" do
225
- it "should discard all matches where the given string is not contained" do
226
- expect(@session).not_to have_no_css("p a", text: "Redirect", count: 1)
227
- expect(@session).to have_no_css("p a", text: "Doesnotexist")
226
+ context 'with text' do
227
+ it 'should discard all matches where the given string is not contained' do
228
+ expect(@session).not_to have_no_css('p a', text: 'Redirect', count: 1)
229
+ expect(@session).to have_no_css('p a', text: 'Doesnotexist')
228
230
  end
229
231
 
230
- it "should discard all matches where the given regexp is not matched" do
231
- expect(@session).not_to have_no_css("p a", text: /re[dab]i/i, count: 1)
232
- expect(@session).to have_no_css("p a", text: /Red$/)
232
+ it 'should discard all matches where the given regexp is not matched' do
233
+ expect(@session).not_to have_no_css('p a', text: /re[dab]i/i, count: 1)
234
+ expect(@session).to have_no_css('p a', text: /Red$/)
233
235
  end
234
236
  end
235
237
  end
@@ -5,73 +5,73 @@ Capybara::SpecHelper.spec '#has_current_path?' do
5
5
  @session.visit('/with_js')
6
6
  end
7
7
 
8
- it "should be true if the page has the given current path" do
8
+ it 'should be true if the page has the given current path' do
9
9
  expect(@session).to have_current_path('/with_js')
10
10
  end
11
11
 
12
- it "should allow regexp matches" do
12
+ it 'should allow regexp matches' do
13
13
  expect(@session).to have_current_path(/w[a-z]{3}_js/)
14
14
  expect(@session).not_to have_current_path(/monkey/)
15
15
  end
16
16
 
17
- it "should not raise an error when non-http" do
17
+ it 'should not raise an error when non-http' do
18
18
  @session.reset_session!
19
19
  expect(@session.has_current_path?(/monkey/)).to eq false
20
- expect(@session.has_current_path?("/with_js")).to eq false
20
+ expect(@session.has_current_path?('/with_js')).to eq false
21
21
  end
22
22
 
23
- it "should handle non-escaped query options" do
24
- @session.click_link("Non-escaped query options")
25
- expect(@session).to have_current_path("/with_html?options[]=things")
23
+ it 'should handle non-escaped query options' do
24
+ @session.click_link('Non-escaped query options')
25
+ expect(@session).to have_current_path('/with_html?options[]=things')
26
26
  end
27
27
 
28
- it "should handle escaped query options" do
29
- @session.click_link("Escaped query options")
30
- expect(@session).to have_current_path("/with_html?options%5B%5D=things")
28
+ it 'should handle escaped query options' do
29
+ @session.click_link('Escaped query options')
30
+ expect(@session).to have_current_path('/with_html?options%5B%5D=things')
31
31
  end
32
32
 
33
- it "should wait for current_path", requires: [:js] do
34
- @session.click_link("Change page")
35
- expect(@session).to have_current_path("/with_html", wait: 3)
33
+ it 'should wait for current_path', requires: [:js] do
34
+ @session.click_link('Change page')
35
+ expect(@session).to have_current_path('/with_html', wait: 3)
36
36
  end
37
37
 
38
- it "should be false if the page has not the given current_path" do
38
+ it 'should be false if the page has not the given current_path' do
39
39
  expect(@session).not_to have_current_path('/with_html')
40
40
  end
41
41
 
42
- it "should check query options" do
42
+ it 'should check query options' do
43
43
  @session.visit('/with_js?test=test')
44
44
  expect(@session).to have_current_path('/with_js?test=test')
45
45
  end
46
46
 
47
- it "should compare the full url if url: true is used" do
47
+ it 'should compare the full url if url: true is used' do
48
48
  expect(@session).to have_current_path(%r{\Ahttp://[^/]*/with_js\Z}, url: true)
49
49
  domain_port = if @session.respond_to?(:server) && @session.server
50
50
  "#{@session.server.host}:#{@session.server.port}"
51
51
  else
52
- "www.example.com"
52
+ 'www.example.com'
53
53
  end
54
54
  expect(@session).to have_current_path("http://#{domain_port}/with_js", url: true)
55
55
  end
56
56
 
57
- it "should not compare the full url if url: true is not passed" do
57
+ it 'should not compare the full url if url: true is not passed' do
58
58
  expect(@session).to have_current_path(%r{^/with_js\Z})
59
59
  expect(@session).to have_current_path('/with_js')
60
60
  end
61
61
 
62
- it "should not compare the full url if url: false is passed" do
62
+ it 'should not compare the full url if url: false is passed' do
63
63
  expect(@session).to have_current_path(%r{^/with_js\Z}, url: false)
64
64
  expect(@session).to have_current_path('/with_js', url: false)
65
65
  end
66
66
 
67
- it "should default to full url if value is a url" do
67
+ it 'should default to full url if value is a url' do
68
68
  url = @session.current_url
69
69
  expect(url).to match(/with_js$/)
70
70
  expect(@session).to have_current_path(url)
71
- expect(@session).not_to have_current_path("http://www.not_example.com/with_js")
71
+ expect(@session).not_to have_current_path('http://www.not_example.com/with_js')
72
72
  end
73
73
 
74
- it "should ignore the query" do
74
+ it 'should ignore the query' do
75
75
  @session.visit('/with_js?test=test')
76
76
  expect(@session).to have_current_path('/with_js?test=test')
77
77
  expect(@session).to have_current_path('/with_js', ignore_query: true)
@@ -80,7 +80,7 @@ Capybara::SpecHelper.spec '#has_current_path?' do
80
80
  expect(@session).to have_current_path(uri.to_s, ignore_query: true)
81
81
  end
82
82
 
83
- it "should not raise an exception if the current_url is nil" do
83
+ it 'should not raise an exception if the current_url is nil' do
84
84
  allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
85
85
 
86
86
  # Without ignore_query option
@@ -100,27 +100,27 @@ Capybara::SpecHelper.spec '#has_no_current_path?' do
100
100
  @session.visit('/with_js')
101
101
  end
102
102
 
103
- it "should be false if the page has the given current_path" do
103
+ it 'should be false if the page has the given current_path' do
104
104
  expect(@session).not_to have_no_current_path('/with_js')
105
105
  end
106
106
 
107
- it "should allow regexp matches" do
107
+ it 'should allow regexp matches' do
108
108
  expect(@session).not_to have_no_current_path(/w[a-z]{3}_js/)
109
109
  expect(@session).to have_no_current_path(/monkey/)
110
110
  end
111
111
 
112
- it "should wait for current_path to disappear", requires: [:js] do
112
+ it 'should wait for current_path to disappear', requires: [:js] do
113
113
  Capybara.using_wait_time(3) do
114
- @session.click_link("Change page")
114
+ @session.click_link('Change page')
115
115
  expect(@session).to have_no_current_path('/with_js')
116
116
  end
117
117
  end
118
118
 
119
- it "should be true if the page has not the given current_path" do
119
+ it 'should be true if the page has not the given current_path' do
120
120
  expect(@session).to have_no_current_path('/with_html')
121
121
  end
122
122
 
123
- it "should not raise an exception if the current_url is nil" do
123
+ it 'should not raise an exception if the current_url is nil' do
124
124
  allow_any_instance_of(Capybara::Session).to receive(:current_url).and_return(nil)
125
125
 
126
126
  # Without ignore_query option