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.
- checksums.yaml +4 -4
- data/History.md +16 -0
- data/README.md +5 -7
- data/lib/capybara.rb +7 -6
- data/lib/capybara/config.rb +1 -1
- data/lib/capybara/dsl.rb +2 -2
- data/lib/capybara/helpers.rb +3 -3
- data/lib/capybara/minitest/spec.rb +3 -3
- data/lib/capybara/node/actions.rb +18 -18
- data/lib/capybara/node/base.rb +1 -1
- data/lib/capybara/node/element.rb +2 -2
- data/lib/capybara/node/finders.rb +6 -6
- data/lib/capybara/node/matchers.rb +5 -5
- data/lib/capybara/node/simple.rb +2 -2
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/base_query.rb +12 -11
- data/lib/capybara/queries/current_path_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +39 -15
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +1 -1
- data/lib/capybara/rack_test/browser.rb +7 -7
- data/lib/capybara/rack_test/driver.rb +1 -1
- data/lib/capybara/rack_test/form.rb +7 -7
- data/lib/capybara/rack_test/node.rb +16 -16
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/result.rb +8 -4
- data/lib/capybara/rspec/features.rb +4 -4
- data/lib/capybara/rspec/matchers.rb +6 -6
- data/lib/capybara/selector.rb +106 -90
- data/lib/capybara/selector/css.rb +4 -4
- data/lib/capybara/selector/filter_set.rb +52 -8
- data/lib/capybara/selector/selector.rb +39 -15
- data/lib/capybara/selenium/driver.rb +10 -10
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +8 -0
- data/lib/capybara/selenium/node.rb +9 -10
- data/lib/capybara/selenium/nodes/chrome_node.rb +18 -0
- data/lib/capybara/selenium/nodes/marionette_node.rb +32 -7
- data/lib/capybara/server.rb +3 -3
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/server/middleware.rb +1 -1
- data/lib/capybara/session.rb +23 -19
- data/lib/capybara/session/config.rb +18 -3
- data/lib/capybara/spec/public/test.js +1 -1
- data/lib/capybara/spec/session/accept_alert_spec.rb +10 -10
- data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -3
- data/lib/capybara/spec/session/accept_prompt_spec.rb +9 -10
- data/lib/capybara/spec/session/all_spec.rb +33 -32
- data/lib/capybara/spec/session/ancestor_spec.rb +19 -19
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +38 -38
- data/lib/capybara/spec/session/assert_current_path_spec.rb +16 -16
- data/lib/capybara/spec/session/assert_selector_spec.rb +53 -53
- data/lib/capybara/spec/session/assert_style_spec.rb +3 -3
- data/lib/capybara/spec/session/assert_text_spec.rb +31 -30
- data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
- data/lib/capybara/spec/session/attach_file_spec.rb +51 -52
- data/lib/capybara/spec/session/body_spec.rb +6 -6
- data/lib/capybara/spec/session/check_spec.rb +52 -47
- data/lib/capybara/spec/session/choose_spec.rb +32 -32
- data/lib/capybara/spec/session/click_button_spec.rb +103 -103
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +24 -23
- data/lib/capybara/spec/session/click_link_spec.rb +49 -48
- data/lib/capybara/spec/session/current_scope_spec.rb +7 -7
- data/lib/capybara/spec/session/current_url_spec.rb +26 -27
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +3 -3
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -2
- data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +8 -8
- data/lib/capybara/spec/session/element/match_css_spec.rb +10 -10
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +51 -51
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
- data/lib/capybara/spec/session/evaluate_script_spec.rb +15 -8
- data/lib/capybara/spec/session/execute_script_spec.rb +7 -7
- data/lib/capybara/spec/session/fill_in_spec.rb +43 -42
- data/lib/capybara/spec/session/find_button_spec.rb +23 -23
- data/lib/capybara/spec/session/find_by_id_spec.rb +7 -7
- data/lib/capybara/spec/session/find_field_spec.rb +32 -30
- data/lib/capybara/spec/session/find_link_spec.rb +21 -21
- data/lib/capybara/spec/session/find_spec.rb +153 -135
- data/lib/capybara/spec/session/first_spec.rb +41 -41
- data/lib/capybara/spec/session/frame/frame_title_spec.rb +5 -5
- data/lib/capybara/spec/session/frame/frame_url_spec.rb +5 -5
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +17 -17
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +31 -17
- data/lib/capybara/spec/session/go_back_spec.rb +1 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/has_button_spec.rb +13 -13
- data/lib/capybara/spec/session/has_css_spec.rb +133 -131
- data/lib/capybara/spec/session/has_current_path_spec.rb +29 -29
- data/lib/capybara/spec/session/has_field_spec.rb +58 -58
- data/lib/capybara/spec/session/has_link_spec.rb +4 -4
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +24 -24
- data/lib/capybara/spec/session/has_select_spec.rb +43 -43
- data/lib/capybara/spec/session/has_selector_spec.rb +71 -71
- data/lib/capybara/spec/session/has_style_spec.rb +3 -3
- data/lib/capybara/spec/session/has_table_spec.rb +4 -4
- data/lib/capybara/spec/session/has_text_spec.rb +53 -52
- data/lib/capybara/spec/session/has_title_spec.rb +14 -14
- data/lib/capybara/spec/session/has_xpath_spec.rb +39 -38
- data/lib/capybara/spec/session/headers_spec.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +6 -6
- data/lib/capybara/spec/session/node_spec.rb +129 -123
- data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
- data/lib/capybara/spec/session/refresh_spec.rb +4 -7
- data/lib/capybara/spec/session/reset_session_spec.rb +28 -28
- data/lib/capybara/spec/session/response_code_spec.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +2 -2
- data/lib/capybara/spec/session/save_page_spec.rb +37 -37
- data/lib/capybara/spec/session/save_screenshot_spec.rb +6 -6
- data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/select_spec.rb +81 -81
- data/lib/capybara/spec/session/selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/sibling_spec.rb +9 -9
- data/lib/capybara/spec/session/text_spec.rb +23 -23
- data/lib/capybara/spec/session/title_spec.rb +5 -5
- data/lib/capybara/spec/session/uncheck_spec.rb +24 -20
- data/lib/capybara/spec/session/unselect_spec.rb +37 -37
- data/lib/capybara/spec/session/visit_spec.rb +48 -49
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -16
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -2
- data/lib/capybara/spec/session/window/window_spec.rb +4 -4
- data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
- data/lib/capybara/spec/session/within_spec.rb +41 -41
- data/lib/capybara/spec/spec_helper.rb +11 -9
- data/lib/capybara/spec/test_app.rb +18 -17
- data/lib/capybara/spec/views/form.erb +29 -31
- data/lib/capybara/spec/views/with_html.erb +2 -2
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +23 -23
- data/spec/capybara_spec.rb +20 -20
- data/spec/css_splitter_spec.rb +7 -7
- data/spec/dsl_spec.rb +37 -32
- data/spec/filter_set_spec.rb +4 -4
- data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +4 -4
- data/spec/minitest_spec_spec.rb +23 -23
- data/spec/per_session_config_spec.rb +5 -5
- data/spec/rack_test_spec.rb +44 -44
- data/spec/result_spec.rb +14 -14
- data/spec/rspec/features_spec.rb +13 -13
- data/spec/rspec/scenarios_spec.rb +4 -4
- data/spec/rspec/shared_spec_matchers.rb +282 -281
- data/spec/rspec/views_spec.rb +3 -3
- data/spec/rspec_matchers_spec.rb +10 -10
- data/spec/rspec_spec.rb +29 -29
- data/spec/selector_spec.rb +64 -64
- data/spec/selenium_spec_chrome.rb +14 -22
- data/spec/selenium_spec_chrome_remote.rb +28 -8
- data/spec/selenium_spec_edge.rb +9 -4
- data/spec/selenium_spec_firefox_remote.rb +87 -0
- data/spec/selenium_spec_ie.rb +9 -4
- data/spec/selenium_spec_marionette.rb +42 -18
- data/spec/server_spec.rb +29 -27
- data/spec/session_spec.rb +17 -17
- data/spec/shared_selenium_session.rb +70 -52
- data/spec/spec_helper.rb +1 -1
- 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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
9
|
-
expect(@session).to have_css(
|
10
|
-
expect(@session).to have_css(
|
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
|
14
|
-
expect(@session).not_to have_css(
|
15
|
-
expect(@session).not_to have_css(
|
16
|
-
expect(@session).not_to have_css(
|
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
|
19
|
+
it 'should respect scopes' do
|
20
20
|
@session.within "//p[@id='first']" do
|
21
|
-
expect(@session).to have_css(
|
22
|
-
expect(@session).not_to have_css(
|
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
|
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
|
33
|
-
it
|
34
|
-
expect(@session).to have_css(
|
35
|
-
expect(@session).to have_css(
|
36
|
-
expect(@session).to have_css(
|
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
|
40
|
-
expect(@session).not_to have_css(
|
41
|
-
expect(@session).not_to have_css(
|
42
|
-
expect(@session).not_to have_css(
|
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
|
47
|
-
it
|
48
|
-
expect(@session).to have_css(
|
49
|
-
expect(@session).to have_css(
|
50
|
-
expect(@session).to have_css(
|
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
|
54
|
-
expect(@session).not_to have_css(
|
55
|
-
expect(@session).not_to have_css(
|
56
|
-
expect(@session).not_to have_css(
|
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
|
60
|
-
expect(@session).to have_css(
|
61
|
-
expect(@session).to have_css(
|
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
|
66
|
-
it
|
67
|
-
expect(@session).to have_css(
|
68
|
-
expect(@session).to have_css(
|
69
|
-
expect(@session).to have_css(
|
70
|
-
expect(@session).to have_css(
|
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
|
74
|
-
expect(@session).not_to have_css(
|
75
|
-
expect(@session).not_to have_css(
|
76
|
-
expect(@session).not_to have_css(
|
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
|
80
|
-
expect(@session).to have_css(
|
81
|
-
expect(@session).to have_css(
|
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
|
86
|
-
it
|
87
|
-
expect(@session).to have_css(
|
88
|
-
expect(@session).to have_css(
|
89
|
-
expect(@session).to have_css(
|
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
|
93
|
-
expect(@session).not_to have_css(
|
94
|
-
expect(@session).not_to have_css(
|
95
|
-
expect(@session).not_to have_css(
|
96
|
-
expect(@session).not_to have_css(
|
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
|
100
|
-
expect(@session).to have_css(
|
101
|
-
expect(@session).to have_css(
|
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
|
106
|
-
it
|
107
|
-
expect(@session).to have_css(
|
108
|
-
expect(@session).not_to have_css(
|
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
|
112
|
-
expect(@session).to have_css(
|
113
|
-
expect(@session).not_to have_css(
|
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
|
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
|
129
|
-
expect(@session).not_to have_no_css(
|
130
|
-
expect(@session).not_to have_no_css(
|
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
|
134
|
-
expect(@session).to have_no_css(
|
135
|
-
expect(@session).to have_no_css(
|
136
|
-
expect(@session).to have_no_css(
|
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
|
140
|
+
it 'should respect scopes' do
|
140
141
|
@session.within "//p[@id='first']" do
|
141
|
-
expect(@session).not_to have_no_css(
|
142
|
-
expect(@session).to have_no_css(
|
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
|
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(
|
151
|
+
expect(@session).to have_no_css('p#change')
|
150
152
|
end
|
151
153
|
|
152
|
-
context
|
153
|
-
it
|
154
|
-
expect(@session).not_to have_no_css(
|
155
|
-
expect(@session).not_to have_no_css(
|
156
|
-
expect(@session).not_to have_no_css(
|
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
|
160
|
-
expect(@session).to have_no_css(
|
161
|
-
expect(@session).to have_no_css(
|
162
|
-
expect(@session).to have_no_css(
|
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
|
167
|
-
it
|
168
|
-
expect(@session).not_to have_no_css(
|
169
|
-
expect(@session).not_to have_no_css(
|
170
|
-
expect(@session).not_to have_no_css(
|
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
|
174
|
-
expect(@session).to have_no_css(
|
175
|
-
expect(@session).to have_no_css(
|
176
|
-
expect(@session).to have_no_css(
|
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
|
180
|
-
expect(@session).not_to have_no_css(
|
181
|
-
expect(@session).not_to have_no_css(
|
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
|
186
|
-
it
|
187
|
-
expect(@session).not_to have_no_css(
|
188
|
-
expect(@session).not_to have_no_css(
|
189
|
-
expect(@session).not_to have_no_css(
|
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
|
193
|
-
expect(@session).to have_no_css(
|
194
|
-
expect(@session).to have_no_css(
|
195
|
-
expect(@session).to have_no_css(
|
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
|
199
|
-
expect(@session).not_to have_no_css(
|
200
|
-
expect(@session).not_to have_no_css(
|
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
|
205
|
-
it
|
206
|
-
expect(@session).not_to have_no_css(
|
207
|
-
expect(@session).not_to have_no_css(
|
208
|
-
expect(@session).not_to have_no_css(
|
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
|
212
|
-
expect(@session).to have_no_css(
|
213
|
-
expect(@session).to have_no_css(
|
214
|
-
expect(@session).to have_no_css(
|
215
|
-
expect(@session).to have_no_css(
|
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
|
219
|
-
expect(@session).not_to have_no_css(
|
220
|
-
expect(@session).not_to have_no_css(
|
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
|
225
|
-
it
|
226
|
-
expect(@session).not_to have_no_css(
|
227
|
-
expect(@session).to have_no_css(
|
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
|
231
|
-
expect(@session).not_to have_no_css(
|
232
|
-
expect(@session).to have_no_css(
|
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
|
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
|
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
|
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?(
|
20
|
+
expect(@session.has_current_path?('/with_js')).to eq false
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
@session.click_link(
|
25
|
-
expect(@session).to have_current_path(
|
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
|
29
|
-
@session.click_link(
|
30
|
-
expect(@session).to have_current_path(
|
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
|
34
|
-
@session.click_link(
|
35
|
-
expect(@session).to have_current_path(
|
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
|
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
|
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
|
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
|
-
|
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
|
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
|
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
|
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(
|
71
|
+
expect(@session).not_to have_current_path('http://www.not_example.com/with_js')
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
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
|
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
|
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
|
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
|
112
|
+
it 'should wait for current_path to disappear', requires: [:js] do
|
113
113
|
Capybara.using_wait_time(3) do
|
114
|
-
@session.click_link(
|
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
|
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
|
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
|