capybara 2.18.0 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +26 -1
- data/README.md +12 -12
- data/lib/capybara.rb +13 -25
- data/lib/capybara/config.rb +11 -57
- data/lib/capybara/cucumber.rb +2 -3
- data/lib/capybara/driver/base.rb +5 -16
- data/lib/capybara/driver/node.rb +5 -4
- data/lib/capybara/dsl.rb +1 -0
- data/lib/capybara/helpers.rb +16 -28
- data/lib/capybara/minitest.rb +139 -138
- data/lib/capybara/minitest/spec.rb +15 -14
- data/lib/capybara/node/actions.rb +59 -81
- data/lib/capybara/node/base.rb +11 -18
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +8 -8
- data/lib/capybara/node/element.rb +30 -40
- data/lib/capybara/node/finders.rb +62 -70
- data/lib/capybara/node/matchers.rb +48 -71
- data/lib/capybara/node/simple.rb +11 -17
- data/lib/capybara/queries/ancestor_query.rb +4 -6
- data/lib/capybara/queries/base_query.rb +18 -17
- data/lib/capybara/queries/current_path_query.rb +8 -24
- data/lib/capybara/queries/match_query.rb +3 -7
- data/lib/capybara/queries/selector_query.rb +92 -95
- data/lib/capybara/queries/sibling_query.rb +4 -4
- data/lib/capybara/queries/text_query.rb +37 -34
- data/lib/capybara/queries/title_query.rb +8 -11
- data/lib/capybara/rack_test/browser.rb +15 -18
- data/lib/capybara/rack_test/css_handlers.rb +6 -4
- data/lib/capybara/rack_test/driver.rb +6 -10
- data/lib/capybara/rack_test/form.rb +50 -40
- data/lib/capybara/rack_test/node.rb +70 -56
- data/lib/capybara/rails.rb +2 -6
- data/lib/capybara/result.rb +22 -22
- data/lib/capybara/rspec.rb +5 -10
- data/lib/capybara/rspec/compound.rb +5 -10
- data/lib/capybara/rspec/features.rb +17 -48
- data/lib/capybara/rspec/matcher_proxies.rb +31 -15
- data/lib/capybara/rspec/matchers.rb +70 -60
- data/lib/capybara/selector.rb +129 -117
- data/lib/capybara/selector/css.rb +6 -11
- data/lib/capybara/selector/filter.rb +1 -17
- data/lib/capybara/selector/filter_set.rb +17 -14
- data/lib/capybara/selector/filters/base.rb +7 -6
- data/lib/capybara/selector/filters/expression_filter.rb +6 -23
- data/lib/capybara/selector/filters/node_filter.rb +2 -12
- data/lib/capybara/selector/selector.rb +27 -33
- data/lib/capybara/selenium/driver.rb +113 -127
- data/lib/capybara/selenium/node.rb +148 -113
- data/lib/capybara/server.rb +3 -2
- data/lib/capybara/session.rb +137 -223
- data/lib/capybara/session/config.rb +47 -67
- data/lib/capybara/session/matchers.rb +8 -7
- data/lib/capybara/spec/public/test.js +26 -4
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -0
- data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -2
- data/lib/capybara/spec/session/accept_prompt_spec.rb +1 -0
- data/lib/capybara/spec/session/all_spec.rb +31 -18
- data/lib/capybara/spec/session/ancestor_spec.rb +2 -4
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +6 -5
- data/lib/capybara/spec/session/assert_current_path.rb +12 -11
- data/lib/capybara/spec/session/assert_selector.rb +1 -0
- data/lib/capybara/spec/session/assert_text.rb +18 -17
- data/lib/capybara/spec/session/assert_title.rb +1 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +14 -13
- data/lib/capybara/spec/session/body_spec.rb +1 -0
- data/lib/capybara/spec/session/check_spec.rb +7 -6
- data/lib/capybara/spec/session/choose_spec.rb +5 -4
- data/lib/capybara/spec/session/click_button_spec.rb +20 -28
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -7
- data/lib/capybara/spec/session/click_link_spec.rb +8 -7
- data/lib/capybara/spec/session/current_scope_spec.rb +4 -3
- data/lib/capybara/spec/session/current_url_spec.rb +7 -6
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -0
- data/lib/capybara/spec/session/element/assert_match_selector.rb +1 -1
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +5 -5
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +3 -2
- data/lib/capybara/spec/session/evaluate_script_spec.rb +4 -3
- data/lib/capybara/spec/session/execute_script_spec.rb +4 -3
- data/lib/capybara/spec/session/fill_in_spec.rb +6 -5
- data/lib/capybara/spec/session/find_button_spec.rb +4 -3
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -1
- data/lib/capybara/spec/session/find_field_spec.rb +8 -14
- data/lib/capybara/spec/session/find_link_spec.rb +6 -5
- data/lib/capybara/spec/session/find_spec.rb +37 -31
- data/lib/capybara/spec/session/first_spec.rb +60 -33
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +9 -16
- data/lib/capybara/spec/session/go_back_spec.rb +1 -0
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -0
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +15 -15
- data/lib/capybara/spec/session/has_button_spec.rb +2 -1
- data/lib/capybara/spec/session/has_css_spec.rb +3 -2
- data/lib/capybara/spec/session/has_current_path_spec.rb +12 -28
- data/lib/capybara/spec/session/has_field_spec.rb +4 -3
- data/lib/capybara/spec/session/has_link_spec.rb +1 -0
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/has_select_spec.rb +30 -29
- data/lib/capybara/spec/session/has_selector_spec.rb +5 -4
- data/lib/capybara/spec/session/has_table_spec.rb +2 -1
- data/lib/capybara/spec/session/has_text_spec.rb +6 -5
- data/lib/capybara/spec/session/has_title_spec.rb +1 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +1 -0
- data/lib/capybara/spec/session/headers.rb +2 -1
- data/lib/capybara/spec/session/html_spec.rb +1 -0
- data/lib/capybara/spec/session/node_spec.rb +91 -56
- data/lib/capybara/spec/session/node_wrapper_spec.rb +36 -0
- data/lib/capybara/spec/session/refresh_spec.rb +4 -2
- data/lib/capybara/spec/session/reset_session_spec.rb +1 -0
- data/lib/capybara/spec/session/response_code.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -11
- data/lib/capybara/spec/session/save_page_spec.rb +1 -17
- data/lib/capybara/spec/session/save_screenshot_spec.rb +1 -1
- data/lib/capybara/spec/session/select_spec.rb +20 -20
- data/lib/capybara/spec/session/selectors_spec.rb +2 -2
- data/lib/capybara/spec/session/sibling_spec.rb +1 -1
- data/lib/capybara/spec/session/text_spec.rb +1 -0
- data/lib/capybara/spec/session/title_spec.rb +1 -1
- data/lib/capybara/spec/session/uncheck_spec.rb +4 -3
- data/lib/capybara/spec/session/unselect_spec.rb +6 -5
- data/lib/capybara/spec/session/visit_spec.rb +9 -3
- data/lib/capybara/spec/session/window/become_closed_spec.rb +2 -1
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +2 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -1
- data/lib/capybara/spec/session/window/window_spec.rb +12 -12
- data/lib/capybara/spec/session/window/windows_spec.rb +2 -3
- data/lib/capybara/spec/session/window/within_window_spec.rb +13 -68
- data/lib/capybara/spec/session/within_spec.rb +1 -0
- data/lib/capybara/spec/spec_helper.rb +26 -18
- data/lib/capybara/spec/test_app.rb +8 -9
- data/lib/capybara/spec/views/form.erb +1 -0
- data/lib/capybara/spec/views/with_html.erb +3 -1
- data/lib/capybara/spec/views/within_frames.erb +4 -1
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +6 -10
- data/spec/basic_node_spec.rb +1 -0
- data/spec/capybara_spec.rb +9 -32
- data/spec/dsl_spec.rb +5 -13
- data/spec/filter_set_spec.rb +5 -4
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +3 -2
- data/spec/minitest_spec.rb +4 -3
- data/spec/minitest_spec_spec.rb +3 -2
- data/spec/per_session_config_spec.rb +9 -8
- data/spec/rack_test_spec.rb +21 -20
- data/spec/result_spec.rb +17 -16
- data/spec/rspec/features_spec.rb +17 -14
- data/spec/rspec/scenarios_spec.rb +5 -7
- data/spec/rspec/shared_spec_matchers.rb +96 -99
- data/spec/rspec/views_spec.rb +2 -1
- data/spec/rspec_matchers_spec.rb +19 -2
- data/spec/rspec_spec.rb +11 -15
- data/spec/selector_spec.rb +5 -6
- data/spec/selenium_spec_chrome.rb +7 -4
- data/spec/selenium_spec_marionette.rb +26 -12
- data/spec/server_spec.rb +33 -33
- data/spec/session_spec.rb +2 -1
- data/spec/shared_selenium_session.rb +27 -21
- data/spec/spec_helper.rb +2 -5
- metadata +66 -87
- data/lib/capybara/query.rb +0 -7
- data/spec/selenium_spec_firefox.rb +0 -68
@@ -1,61 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'delegate'
|
3
4
|
|
4
5
|
module Capybara
|
5
6
|
class SessionConfig
|
6
|
-
OPTIONS = [
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
OPTIONS = %i[always_include_port run_server default_selector default_max_wait_time ignore_hidden_elements
|
8
|
+
automatic_reload match exact exact_text raise_server_errors visible_text_only
|
9
|
+
automatic_label_click enable_aria_label save_path asset_host default_host app_host
|
10
|
+
server_host server_port server_errors].freeze
|
10
11
|
|
11
12
|
attr_accessor(*OPTIONS)
|
12
13
|
|
13
14
|
##
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
#
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
-
#
|
26
|
-
|
27
|
-
#
|
28
|
-
|
29
|
-
#
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
#
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
#
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
|
46
|
-
#
|
47
|
-
|
48
|
-
#
|
49
|
-
|
50
|
-
#
|
51
|
-
|
52
|
-
# See {Capybara.configure}
|
53
|
-
#@!method server_host
|
54
|
-
# See {Capybara.configure}
|
55
|
-
#@!method server_port
|
56
|
-
# See {Capybara.configure}
|
57
|
-
#@!method server_errors
|
58
|
-
# See {Capybara.configure}
|
15
|
+
# @!method always_include_port
|
16
|
+
# See {Capybara.configure}
|
17
|
+
# @!method run_server
|
18
|
+
# See {Capybara.configure}
|
19
|
+
# @!method default_selector
|
20
|
+
# See {Capybara.configure}
|
21
|
+
# @!method default_max_wait_time
|
22
|
+
# See {Capybara.configure}
|
23
|
+
# @!method ignore_hidden_elements
|
24
|
+
# See {Capybara.configure}
|
25
|
+
# @!method automatic_reload
|
26
|
+
# See {Capybara.configure}
|
27
|
+
# @!method match
|
28
|
+
# See {Capybara.configure}
|
29
|
+
# @!method exact
|
30
|
+
# See {Capybara.configure}
|
31
|
+
# @!method raise_server_errors
|
32
|
+
# See {Capybara.configure}
|
33
|
+
# @!method visible_text_only
|
34
|
+
# See {Capybara.configure}
|
35
|
+
# @!method automatic_label_click
|
36
|
+
# See {Capybara.configure}
|
37
|
+
# @!method enable_aria_label
|
38
|
+
# See {Capybara.configure}
|
39
|
+
# @!method save_path
|
40
|
+
# See {Capybara.configure}
|
41
|
+
# @!method asset_host
|
42
|
+
# See {Capybara.configure}
|
43
|
+
# @!method default_host
|
44
|
+
# See {Capybara.configure}
|
45
|
+
# @!method app_host
|
46
|
+
# See {Capybara.configure}
|
47
|
+
# @!method server_host
|
48
|
+
# See {Capybara.configure}
|
49
|
+
# @!method server_port
|
50
|
+
# See {Capybara.configure}
|
51
|
+
# @!method server_errors
|
52
|
+
# See {Capybara.configure}
|
59
53
|
|
60
54
|
remove_method :server_host
|
61
55
|
|
@@ -74,30 +68,16 @@ module Capybara
|
|
74
68
|
|
75
69
|
remove_method :app_host=
|
76
70
|
def app_host=(url)
|
77
|
-
raise ArgumentError
|
71
|
+
raise ArgumentError, "Capybara.app_host should be set to a url (http://www.example.com). Attempted to set #{url.inspect}." if url && url !~ URI::DEFAULT_PARSER.make_regexp
|
78
72
|
@app_host = url
|
79
73
|
end
|
80
74
|
|
81
75
|
remove_method :default_host=
|
82
76
|
def default_host=(url)
|
83
|
-
raise ArgumentError
|
77
|
+
raise ArgumentError, "Capybara.default_host should be set to a url (http://www.example.com). Attempted to set #{url.inspect}." if url && url !~ URI::DEFAULT_PARSER.make_regexp
|
84
78
|
@default_host = url
|
85
79
|
end
|
86
80
|
|
87
|
-
remove_method :save_and_open_page_path=
|
88
|
-
def save_and_open_page_path=(path)
|
89
|
-
warn "DEPRECATED: #save_and_open_page_path is deprecated, please use #save_path instead. \n"\
|
90
|
-
"Note: Behavior is slightly different with relative paths - see documentation" unless path.nil?
|
91
|
-
@save_and_open_page_path = path
|
92
|
-
end
|
93
|
-
|
94
|
-
remove_method :exact_options=
|
95
|
-
def exact_options=(opt)
|
96
|
-
@exact_options = opt
|
97
|
-
warn "DEPRECATED: #exact_options is deprecated, please scope your findes/actions and use the `:exact` "\
|
98
|
-
"option if similar functionality is needed."
|
99
|
-
end
|
100
|
-
|
101
81
|
def initialize_copy(other)
|
102
82
|
super
|
103
83
|
@server_errors = @server_errors.dup
|
@@ -106,9 +86,9 @@ module Capybara
|
|
106
86
|
|
107
87
|
class ReadOnlySessionConfig < SimpleDelegator
|
108
88
|
SessionConfig::OPTIONS.each do |m|
|
109
|
-
define_method "#{m}=" do |
|
89
|
+
define_method "#{m}=" do |_|
|
110
90
|
raise "Per session settings are only supported when Capybara.threadsafe == true"
|
111
91
|
end
|
112
92
|
end
|
113
93
|
end
|
114
|
-
end
|
94
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Capybara
|
3
4
|
module SessionMatchers
|
4
5
|
##
|
@@ -18,8 +19,8 @@ module Capybara
|
|
18
19
|
# @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time
|
19
20
|
# @return [true]
|
20
21
|
#
|
21
|
-
def assert_current_path(path, options
|
22
|
-
_verify_current_path(path,options) { |query| raise Capybara::ExpectationNotMet, query.failure_message unless query.resolves_for?(self) }
|
22
|
+
def assert_current_path(path, **options)
|
23
|
+
_verify_current_path(path, options) { |query| raise Capybara::ExpectationNotMet, query.failure_message unless query.resolves_for?(self) }
|
23
24
|
end
|
24
25
|
|
25
26
|
##
|
@@ -32,8 +33,8 @@ module Capybara
|
|
32
33
|
# @raise [Capybara::ExpectationNotMet] if the assertion hasn't succeeded during wait time
|
33
34
|
# @return [true]
|
34
35
|
#
|
35
|
-
def assert_no_current_path(path, options
|
36
|
-
_verify_current_path(path,options) { |query| raise Capybara::ExpectationNotMet, query.negative_failure_message if query.resolves_for?(self) }
|
36
|
+
def assert_no_current_path(path, **options)
|
37
|
+
_verify_current_path(path, options) { |query| raise Capybara::ExpectationNotMet, query.negative_failure_message if query.resolves_for?(self) }
|
37
38
|
end
|
38
39
|
|
39
40
|
##
|
@@ -45,7 +46,7 @@ module Capybara
|
|
45
46
|
# @macro current_path_query_params
|
46
47
|
# @return [Boolean]
|
47
48
|
#
|
48
|
-
def has_current_path?(path, options
|
49
|
+
def has_current_path?(path, **options)
|
49
50
|
assert_current_path(path, options)
|
50
51
|
rescue Capybara::ExpectationNotMet
|
51
52
|
return false
|
@@ -60,13 +61,13 @@ module Capybara
|
|
60
61
|
# @macro current_path_query_params
|
61
62
|
# @return [Boolean]
|
62
63
|
#
|
63
|
-
def has_no_current_path?(path, options
|
64
|
+
def has_no_current_path?(path, **options)
|
64
65
|
assert_no_current_path(path, options)
|
65
66
|
rescue Capybara::ExpectationNotMet
|
66
67
|
return false
|
67
68
|
end
|
68
69
|
|
69
|
-
|
70
|
+
private
|
70
71
|
|
71
72
|
def _verify_current_path(path, options)
|
72
73
|
query = Capybara::Queries::CurrentPathQuery.new(path, options)
|
@@ -8,7 +8,8 @@ $(function() {
|
|
8
8
|
$(this).html('Dropped!');
|
9
9
|
}
|
10
10
|
});
|
11
|
-
$('#clickable').click(function() {
|
11
|
+
$('#clickable').click(function(e) {
|
12
|
+
debugger;
|
12
13
|
var link = $(this);
|
13
14
|
setTimeout(function() {
|
14
15
|
$(link).after('<a id="has-been-clicked" href="#">Has been clicked</a>');
|
@@ -64,12 +65,33 @@ $(function() {
|
|
64
65
|
}, 400)
|
65
66
|
});
|
66
67
|
$('#click-test').on({
|
67
|
-
|
68
|
-
|
68
|
+
click: function(e) {
|
69
|
+
var desc = "";
|
70
|
+
if (e.altKey) desc += 'alt ';
|
71
|
+
if (e.ctrlKey) desc += 'control ';
|
72
|
+
if (e.metaKey) desc += 'meta ';
|
73
|
+
if (e.shiftKey) desc += 'shift ';
|
74
|
+
var pos = this.getBoundingClientRect();
|
75
|
+
$(this).after('<a id="has-been-clicked" href="#">Has been ' + desc + 'clicked at ' + (e.clientX - pos.left) + ',' + (e.clientY - pos.top) + '</a>');
|
76
|
+
},
|
77
|
+
dblclick: function(e) {
|
78
|
+
var desc = "";
|
79
|
+
if (e.altKey) desc += 'alt ';
|
80
|
+
if (e.ctrlKey) desc += 'control ';
|
81
|
+
if (e.metaKey) desc += 'meta ';
|
82
|
+
if (e.shiftKey) desc += 'shift ';
|
83
|
+
var pos = this.getBoundingClientRect();
|
84
|
+
$(this).after('<a id="has-been-double-clicked" href="#">Has been ' + desc + 'double clicked at ' + (e.clientX - pos.left) + ',' + (e.clientY - pos.top) + '</a>');
|
69
85
|
},
|
70
86
|
contextmenu: function(e) {
|
71
87
|
e.preventDefault();
|
72
|
-
|
88
|
+
var desc = "";
|
89
|
+
if (e.altKey) desc += 'alt ';
|
90
|
+
if (e.ctrlKey) desc += 'control ';
|
91
|
+
if (e.metaKey) desc += 'meta ';
|
92
|
+
if (e.shiftKey) desc += 'shift ';
|
93
|
+
var pos = this.getBoundingClientRect();
|
94
|
+
$(this).after('<a id="has-been-right-clicked" href="#">Has been ' + desc + 'right clicked at ' + (e.clientX - pos.left) + ',' + (e.clientY - pos.top) + '</a>');
|
73
95
|
}
|
74
96
|
});
|
75
97
|
$('#open-alert').click(function() {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#accept_confirm', requires: [:modals] do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_js')
|
@@ -19,13 +20,13 @@ Capybara::SpecHelper.spec '#accept_confirm', requires: [:modals] do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should work with nested modals" do
|
22
|
-
expect
|
23
|
+
expect do
|
23
24
|
@session.dismiss_confirm 'Are you really sure?' do
|
24
25
|
@session.accept_confirm 'Are you sure?' do
|
25
26
|
@session.click_link('Open check twice')
|
26
27
|
end
|
27
28
|
end
|
28
|
-
|
29
|
+
end.not_to raise_error
|
29
30
|
expect(@session).to have_xpath("//a[@id='open-twice' and @confirmed='false']")
|
30
31
|
end
|
31
32
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec "#all" do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_html')
|
@@ -14,11 +15,23 @@ Capybara::SpecHelper.spec "#all" do
|
|
14
15
|
expect(@session.all('//div[@id="nosuchthing"]')).to be_empty
|
15
16
|
end
|
16
17
|
|
17
|
-
it "should
|
18
|
+
it "should wait for matching elements to appear", requires: [:js] do
|
19
|
+
@session.visit('/with_js')
|
20
|
+
@session.click_link('Click me')
|
21
|
+
expect(@session.all(:css, "a#has-been-clicked")).not_to be_empty
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not wait if `minimum: 0` option is specified", requires: [:js] do
|
25
|
+
@session.visit('/with_js')
|
26
|
+
@session.click_link('Click me')
|
27
|
+
expect(@session.all(:css, "a#has-been-clicked", minimum: 0)).to be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should accept an XPath instance", :exact_false do
|
18
31
|
@session.visit('/form')
|
19
32
|
@xpath = Capybara::Selector.all[:fillable_field].call('Name')
|
20
33
|
expect(@xpath).to be_a(::XPath::Union)
|
21
|
-
@result = @session.all(@xpath).map
|
34
|
+
@result = @session.all(@xpath).map(&:value)
|
22
35
|
expect(@result).to include('Smith', 'John', 'John Smith')
|
23
36
|
end
|
24
37
|
|
@@ -116,35 +129,35 @@ Capybara::SpecHelper.spec "#all" do
|
|
116
129
|
|
117
130
|
context 'with multiple count filters' do
|
118
131
|
it 'ignores other filters when :count is specified' do
|
119
|
-
o = {count: 4,
|
120
|
-
|
121
|
-
|
122
|
-
|
132
|
+
o = { count: 4,
|
133
|
+
minimum: 5,
|
134
|
+
maximum: 0,
|
135
|
+
between: 0..3 }
|
123
136
|
expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
|
124
137
|
end
|
125
138
|
context 'with no :count expectation' do
|
126
139
|
it 'fails if :minimum is not met' do
|
127
|
-
o = {minimum: 5,
|
128
|
-
|
129
|
-
|
140
|
+
o = { minimum: 5,
|
141
|
+
maximum: 4,
|
142
|
+
between: 2..7 }
|
130
143
|
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
131
144
|
end
|
132
145
|
it 'fails if :maximum is not met' do
|
133
|
-
o = {minimum: 0,
|
134
|
-
|
135
|
-
|
146
|
+
o = { minimum: 0,
|
147
|
+
maximum: 0,
|
148
|
+
between: 2..7 }
|
136
149
|
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
137
150
|
end
|
138
151
|
it 'fails if :between is not met' do
|
139
|
-
o = {minimum: 0,
|
140
|
-
|
141
|
-
|
152
|
+
o = { minimum: 0,
|
153
|
+
maximum: 4,
|
154
|
+
between: 0..3 }
|
142
155
|
expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
|
143
156
|
end
|
144
157
|
it 'succeeds if all combineable expectations are met' do
|
145
|
-
o = {minimum: 0,
|
146
|
-
|
147
|
-
|
158
|
+
o = { minimum: 0,
|
159
|
+
maximum: 4,
|
160
|
+
between: 2..7 }
|
148
161
|
expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
|
149
162
|
end
|
150
163
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#ancestor' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_html')
|
@@ -57,7 +58,6 @@ Capybara::SpecHelper.spec '#ancestor' do
|
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
|
-
|
61
61
|
it "should raise ElementNotFound with a useful default message if nothing was found" do
|
62
62
|
el = @session.find(:css, '#child')
|
63
63
|
expect do
|
@@ -65,13 +65,11 @@ Capybara::SpecHelper.spec '#ancestor' do
|
|
65
65
|
end.to raise_error(Capybara::ElementNotFound, "Unable to find xpath \"//div[@id=\\\"nosuchthing\\\"]\" that is an ancestor of visible css \"#child\"")
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
68
|
context "within a scope" do
|
71
69
|
it "should limit the ancestors to inside the scope" do
|
72
70
|
@session.within(:css, '#ancestor2') do
|
73
71
|
el = @session.find(:css, '#child')
|
74
|
-
expect(el.ancestor(:css,'div', text: 'Ancestor')[:id]).to eq('ancestor1')
|
72
|
+
expect(el.ancestor(:css, 'div', text: 'Ancestor')[:id]).to eq('ancestor1')
|
75
73
|
end
|
76
74
|
end
|
77
75
|
end
|
@@ -1,21 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#assert_all_of_selectors' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_html')
|
5
6
|
end
|
6
7
|
|
7
8
|
it "should be true if the given selectors are on the page" do
|
8
|
-
@session.assert_all_of_selectors(:css, "p a#foo", "h2#h2one", "h2#h2two"
|
9
|
+
@session.assert_all_of_selectors(:css, "p a#foo", "h2#h2one", "h2#h2two")
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should be false if any of the given selectors are not on the page" do
|
12
|
-
expect { @session.assert_all_of_selectors(:css, "p a#foo", "h2#h2three", "h2#h2one")}.to raise_error(Capybara::ElementNotFound)
|
13
|
+
expect { @session.assert_all_of_selectors(:css, "p a#foo", "h2#h2three", "h2#h2one") }.to raise_error(Capybara::ElementNotFound)
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should use default selector" do
|
16
17
|
Capybara.default_selector = :css
|
17
|
-
expect { @session.assert_all_of_selectors("p a#foo", "h2#h2three", "h2#h2one")}.to raise_error(Capybara::ElementNotFound)
|
18
|
-
@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")
|
19
20
|
end
|
20
21
|
|
21
22
|
context "should respect scopes" do
|
@@ -63,7 +64,7 @@ Capybara::SpecHelper.spec '#assert_none_of_selectors' do
|
|
63
64
|
end
|
64
65
|
|
65
66
|
it "should be true if none of the given locators are on the page" do
|
66
|
-
@session.assert_none_of_selectors(:xpath, "//abbr", "//td"
|
67
|
+
@session.assert_none_of_selectors(:xpath, "//abbr", "//td")
|
67
68
|
@session.assert_none_of_selectors(:css, "p a#doesnotexist", "abbr")
|
68
69
|
end
|
69
70
|
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#assert_current_path' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_js')
|
5
6
|
end
|
6
7
|
|
7
8
|
it "should not raise if the page has the given current path" do
|
8
|
-
expect {@session.assert_current_path('/with_js')}.not_to raise_error
|
9
|
+
expect { @session.assert_current_path('/with_js') }.not_to raise_error
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should allow regexp matches" do
|
@@ -18,27 +19,27 @@ Capybara::SpecHelper.spec '#assert_current_path' do
|
|
18
19
|
end
|
19
20
|
|
20
21
|
it "should raise if the page has not the given current_path" do
|
21
|
-
expect{@session.assert_current_path('/with_html')}.to raise_error(Capybara::ExpectationNotMet, 'expected "/with_js" to equal "/with_html"')
|
22
|
+
expect { @session.assert_current_path('/with_html') }.to raise_error(Capybara::ExpectationNotMet, 'expected "/with_js" to equal "/with_html"')
|
22
23
|
end
|
23
24
|
|
24
25
|
it "should check query options" do
|
25
26
|
@session.visit('/with_js?test=test')
|
26
|
-
expect{@session.assert_current_path('/with_js?test=test')}.not_to raise_error
|
27
|
+
expect { @session.assert_current_path('/with_js?test=test') }.not_to raise_error
|
27
28
|
end
|
28
29
|
|
29
30
|
it "should compare the full url" do
|
30
|
-
expect{@session.assert_current_path(%r{\Ahttp://[^/]*/with_js\Z}, url: true)}.not_to raise_error
|
31
|
+
expect { @session.assert_current_path(%r{\Ahttp://[^/]*/with_js\Z}, url: true) }.not_to raise_error
|
31
32
|
end
|
32
33
|
|
33
34
|
it "should ignore the query" do
|
34
35
|
@session.visit('/with_js?test=test')
|
35
|
-
expect{@session.assert_current_path('/with_js',
|
36
|
+
expect { @session.assert_current_path('/with_js', ignore_query: true) }.not_to raise_error
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should not cause an exception when current_url is nil" do
|
39
40
|
allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil }
|
40
41
|
|
41
|
-
expect{@session.assert_current_path(nil)}.not_to raise_error
|
42
|
+
expect { @session.assert_current_path(nil) }.not_to raise_error
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
@@ -48,25 +49,25 @@ Capybara::SpecHelper.spec '#assert_no_current_path?' do
|
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should raise if the page has the given current_path" do
|
51
|
-
expect{@session.assert_no_current_path('/with_js')}.to raise_error(Capybara::ExpectationNotMet)
|
52
|
+
expect { @session.assert_no_current_path('/with_js') }.to raise_error(Capybara::ExpectationNotMet)
|
52
53
|
end
|
53
54
|
|
54
55
|
it "should allow regexp matches" do
|
55
|
-
expect{@session.assert_no_current_path(/monkey/)}.not_to raise_error
|
56
|
+
expect { @session.assert_no_current_path(/monkey/) }.not_to raise_error
|
56
57
|
end
|
57
58
|
|
58
59
|
it "should wait for current_path to disappear", requires: [:js] do
|
59
60
|
@session.click_link("Change page")
|
60
|
-
expect{@session.assert_no_current_path('/with_js')}.not_to raise_error
|
61
|
+
expect { @session.assert_no_current_path('/with_js') }.not_to raise_error
|
61
62
|
end
|
62
63
|
|
63
64
|
it "should not raise if the page has not the given current_path" do
|
64
|
-
expect{@session.assert_no_current_path('/with_html')}.not_to raise_error
|
65
|
+
expect { @session.assert_no_current_path('/with_html') }.not_to raise_error
|
65
66
|
end
|
66
67
|
|
67
68
|
it "should not cause an exception when current_url is nil" do
|
68
69
|
allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil }
|
69
70
|
|
70
|
-
expect{@session.assert_no_current_path('/with_html')}.not_to raise_error
|
71
|
+
expect { @session.assert_no_current_path('/with_html') }.not_to raise_error
|
71
72
|
end
|
72
73
|
end
|