capybara 1.1.4 → 2.0.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.
- data/{History.txt → History.md} +138 -0
- data/License.txt +22 -0
- data/README.md +850 -0
- data/lib/capybara/cucumber.rb +2 -5
- data/lib/capybara/driver/base.rb +6 -6
- data/lib/capybara/driver/node.rb +3 -2
- data/lib/capybara/dsl.rb +13 -124
- data/lib/capybara/helpers.rb +33 -0
- data/lib/capybara/node/actions.rb +16 -30
- data/lib/capybara/node/base.rb +56 -13
- data/lib/capybara/node/element.rb +18 -30
- data/lib/capybara/node/finders.rb +28 -90
- data/lib/capybara/node/matchers.rb +121 -73
- data/lib/capybara/node/simple.rb +13 -11
- data/lib/capybara/query.rb +78 -0
- data/lib/capybara/rack_test/browser.rb +27 -39
- data/lib/capybara/rack_test/driver.rb +13 -3
- data/lib/capybara/rack_test/node.rb +31 -2
- data/lib/capybara/result.rb +72 -0
- data/lib/capybara/rspec/features.rb +4 -1
- data/lib/capybara/rspec/matchers.rb +33 -63
- data/lib/capybara/rspec.rb +7 -4
- data/lib/capybara/selector.rb +97 -34
- data/lib/capybara/selenium/driver.rb +15 -62
- data/lib/capybara/selenium/node.rb +14 -21
- data/lib/capybara/server.rb +32 -27
- data/lib/capybara/session.rb +90 -50
- data/lib/capybara/spec/fixtures/another_test_file.txt +1 -0
- data/lib/capybara/spec/public/jquery-ui.js +791 -0
- data/lib/capybara/spec/public/jquery.js +9046 -0
- data/lib/capybara/spec/public/test.js +3 -0
- data/lib/capybara/spec/session/all_spec.rb +61 -59
- data/lib/capybara/spec/session/assert_selector.rb +123 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +72 -55
- data/lib/capybara/spec/session/body_spec.rb +21 -0
- data/lib/capybara/spec/session/check_spec.rb +68 -48
- data/lib/capybara/spec/session/choose_spec.rb +32 -18
- data/lib/capybara/spec/session/click_button_spec.rb +263 -232
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +40 -29
- data/lib/capybara/spec/session/click_link_spec.rb +96 -96
- data/lib/capybara/spec/session/current_url_spec.rb +88 -10
- data/lib/capybara/spec/session/evaluate_script_spec.rb +6 -0
- data/lib/capybara/spec/session/execute_script_spec.rb +7 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +119 -103
- data/lib/capybara/spec/session/find_button_spec.rb +16 -14
- data/lib/capybara/spec/session/find_by_id_spec.rb +16 -14
- data/lib/capybara/spec/session/find_field_spec.rb +23 -21
- data/lib/capybara/spec/session/find_link_spec.rb +15 -14
- data/lib/capybara/spec/session/find_spec.rb +93 -115
- data/lib/capybara/spec/session/first_spec.rb +51 -85
- data/lib/capybara/spec/session/has_button_spec.rb +22 -24
- data/lib/capybara/spec/session/has_css_spec.rb +190 -205
- data/lib/capybara/spec/session/has_field_spec.rb +170 -144
- data/lib/capybara/spec/session/has_link_spec.rb +26 -29
- data/lib/capybara/spec/session/has_select_spec.rb +161 -109
- data/lib/capybara/spec/session/has_selector_spec.rb +94 -100
- data/lib/capybara/spec/session/has_table_spec.rb +22 -88
- data/lib/capybara/spec/session/has_text_spec.rb +195 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +100 -96
- data/lib/capybara/spec/session/headers.rb +4 -17
- data/lib/capybara/spec/session/html_spec.rb +15 -0
- data/lib/capybara/spec/session/node_spec.rb +205 -0
- data/lib/capybara/spec/session/reset_session_spec.rb +42 -0
- data/lib/capybara/spec/session/response_code.rb +4 -17
- data/lib/capybara/spec/session/save_page_spec.rb +46 -0
- data/lib/capybara/spec/session/screenshot.rb +13 -0
- data/lib/capybara/spec/session/select_spec.rb +99 -88
- data/lib/capybara/spec/session/source_spec.rb +12 -0
- data/lib/capybara/spec/session/text_spec.rb +15 -12
- data/lib/capybara/spec/session/uncheck_spec.rb +22 -17
- data/lib/capybara/spec/session/unselect_spec.rb +69 -58
- data/lib/capybara/spec/session/visit_spec.rb +74 -0
- data/lib/capybara/spec/session/within_frame_spec.rb +31 -0
- data/lib/capybara/spec/session/within_spec.rb +118 -131
- data/lib/capybara/spec/session/within_window_spec.rb +38 -0
- data/lib/capybara/spec/spec_helper.rb +84 -0
- data/lib/capybara/spec/test_app.rb +32 -6
- data/lib/capybara/spec/views/form.erb +12 -10
- data/lib/capybara/spec/views/host_links.erb +2 -2
- data/lib/capybara/spec/views/tables.erb +6 -66
- data/lib/capybara/spec/views/with_html.erb +9 -4
- data/lib/capybara/spec/views/with_js.erb +11 -7
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara.rb +125 -6
- data/spec/basic_node_spec.rb +17 -5
- data/spec/capybara_spec.rb +9 -0
- data/spec/dsl_spec.rb +31 -17
- data/spec/rack_test_spec.rb +157 -0
- data/spec/result_spec.rb +51 -0
- data/spec/rspec/features_spec.rb +19 -2
- data/spec/rspec/matchers_spec.rb +170 -89
- data/spec/rspec_spec.rb +1 -3
- data/spec/selenium_spec.rb +53 -0
- data/spec/server_spec.rb +37 -25
- data/spec/spec_helper.rb +1 -30
- metadata +39 -31
- data/README.rdoc +0 -722
- data/lib/capybara/spec/driver.rb +0 -301
- data/lib/capybara/spec/session/current_host_spec.rb +0 -68
- data/lib/capybara/spec/session/has_content_spec.rb +0 -106
- data/lib/capybara/spec/session/javascript.rb +0 -306
- data/lib/capybara/spec/session.rb +0 -154
- data/lib/capybara/util/save_and_open_page.rb +0 -44
- data/lib/capybara/util/timeout.rb +0 -27
- data/spec/driver/rack_test_driver_spec.rb +0 -89
- data/spec/driver/selenium_driver_spec.rb +0 -37
- data/spec/save_and_open_page_spec.rb +0 -155
- data/spec/session/rack_test_session_spec.rb +0 -55
- data/spec/session/selenium_session_spec.rb +0 -26
- data/spec/string_spec.rb +0 -77
- data/spec/timeout_spec.rb +0 -28
|
@@ -1,129 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should be false if the field is not on the page" do
|
|
12
|
-
@session.should_not have_select('Monkey')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context 'with selected value' do
|
|
16
|
-
it "should be true if a field with the given value is on the page" do
|
|
17
|
-
@session.should have_select('form_locale', :selected => 'English')
|
|
18
|
-
@session.should have_select('Region', :selected => 'Norway')
|
|
19
|
-
@session.should have_select('Underwear', :selected => ['Briefs', 'Commando'])
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should be false if the given field is not on the page" do
|
|
23
|
-
@session.should_not have_select('Locale', :selected => 'Swedish')
|
|
24
|
-
@session.should_not have_select('Does not exist', :selected => 'John')
|
|
25
|
-
@session.should_not have_select('City', :selected => 'Not there')
|
|
26
|
-
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Nonexistant'])
|
|
27
|
-
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Boxers'])
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should be true after the given value is selected" do
|
|
31
|
-
@session.select('Swedish', :from => 'Locale')
|
|
32
|
-
@session.should have_select('Locale', :selected => 'Swedish')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should be false after a different value is selected" do
|
|
36
|
-
@session.select('Swedish', :from => 'Locale')
|
|
37
|
-
@session.should_not have_select('Locale', :selected => 'English')
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should be true after the given values are selected" do
|
|
41
|
-
@session.select('Boxers', :from => 'Underwear')
|
|
42
|
-
@session.should have_select('Underwear', :selected => ['Briefs', 'Boxers', 'Commando'])
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should be false after one of the values is unselected" do
|
|
46
|
-
@session.unselect('Briefs', :from => 'Underwear')
|
|
47
|
-
@session.should_not have_select('Underwear', :selected => ['Briefs', 'Commando'])
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context 'with options' do
|
|
52
|
-
it "should be true if a field with the given options is on the page" do
|
|
53
|
-
@session.should have_select('form_locale', :options => ['English'])
|
|
54
|
-
@session.should have_select('Region', :options => ['Norway', 'Sweden'])
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it "should be false if the given field is not on the page" do
|
|
58
|
-
@session.should_not have_select('Locale', :options => ['Not there'])
|
|
59
|
-
@session.should_not have_select('Does not exist', :options => ['John'])
|
|
60
|
-
@session.should_not have_select('City', :options => ['London', 'Made up city'])
|
|
61
|
-
end
|
|
62
|
-
end
|
|
1
|
+
Capybara::SpecHelper.spec '#has_select?' do
|
|
2
|
+
before { @session.visit('/form') }
|
|
3
|
+
|
|
4
|
+
it "should be true if the field is on the page" do
|
|
5
|
+
@session.should have_select('Locale')
|
|
6
|
+
@session.should have_select('form_region')
|
|
7
|
+
@session.should have_select('Languages')
|
|
8
|
+
@session.should have_select(:'Languages')
|
|
63
9
|
end
|
|
64
10
|
|
|
65
|
-
|
|
66
|
-
|
|
11
|
+
it "should be false if the field is not on the page" do
|
|
12
|
+
@session.should_not have_select('Monkey')
|
|
13
|
+
end
|
|
67
14
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@session.
|
|
71
|
-
@session.
|
|
15
|
+
context 'with selected value' do
|
|
16
|
+
it "should be true if a field with the given value is on the page" do
|
|
17
|
+
@session.should have_select('form_locale', :selected => 'English')
|
|
18
|
+
@session.should have_select('Region', :selected => 'Norway')
|
|
19
|
+
@session.should have_select('Underwear', :selected => [
|
|
20
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
21
|
+
])
|
|
72
22
|
end
|
|
73
23
|
|
|
74
|
-
it "should be
|
|
75
|
-
@session.
|
|
24
|
+
it "should be false if the given field is not on the page" do
|
|
25
|
+
@session.should_not have_select('Locale', :selected => 'Swedish')
|
|
26
|
+
@session.should_not have_select('Does not exist', :selected => 'John')
|
|
27
|
+
@session.should_not have_select('City', :selected => 'Not there')
|
|
28
|
+
@session.should_not have_select('Underwear', :selected => [
|
|
29
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
|
30
|
+
])
|
|
31
|
+
@session.should_not have_select('Underwear', :selected => [
|
|
32
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
33
|
+
])
|
|
34
|
+
@session.should_not have_select('Underwear', :selected => [
|
|
35
|
+
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
|
36
|
+
])
|
|
76
37
|
end
|
|
77
38
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@session.should_not have_no_select('Underwear', :selected => ['Briefs', 'Commando'])
|
|
83
|
-
end
|
|
39
|
+
it "should be true after the given value is selected" do
|
|
40
|
+
@session.select('Swedish', :from => 'Locale')
|
|
41
|
+
@session.should have_select('Locale', :selected => 'Swedish')
|
|
42
|
+
end
|
|
84
43
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
@session.should have_no_select('Underwear', :selected => ['Briefs', 'Nonexistant'])
|
|
90
|
-
@session.should have_no_select('Underwear', :selected => ['Briefs', 'Boxers'])
|
|
91
|
-
end
|
|
44
|
+
it "should be false after a different value is selected" do
|
|
45
|
+
@session.select('Swedish', :from => 'Locale')
|
|
46
|
+
@session.should_not have_select('Locale', :selected => 'English')
|
|
47
|
+
end
|
|
92
48
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
49
|
+
it "should be true after the given values are selected" do
|
|
50
|
+
@session.select('Boxers', :from => 'Underwear')
|
|
51
|
+
@session.should have_select('Underwear', :selected => [
|
|
52
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
53
|
+
])
|
|
54
|
+
end
|
|
97
55
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
56
|
+
it "should be false after one of the values is unselected" do
|
|
57
|
+
@session.unselect('Briefs', :from => 'Underwear')
|
|
58
|
+
@session.should_not have_select('Underwear', :selected => [
|
|
59
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
60
|
+
])
|
|
61
|
+
end
|
|
62
|
+
end
|
|
102
63
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
64
|
+
context 'with exact options' do
|
|
65
|
+
it "should be true if a field with the given options is on the page" do
|
|
66
|
+
@session.should have_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
|
67
|
+
@session.should have_select('Tendency', :options => [])
|
|
68
|
+
end
|
|
107
69
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
70
|
+
it "should be false if the given field is not on the page" do
|
|
71
|
+
@session.should_not have_select('Locale', :options => ['Swedish'])
|
|
72
|
+
@session.should_not have_select('Does not exist', :options => ['John'])
|
|
73
|
+
@session.should_not have_select('City', :options => ['London', 'Made up city'])
|
|
74
|
+
@session.should_not have_select('Region', :options => ['Norway', 'Sweden'])
|
|
75
|
+
@session.should_not have_select('Region', :options => ['Norway', 'Norway', 'Norway'])
|
|
112
76
|
end
|
|
77
|
+
end
|
|
113
78
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
79
|
+
context 'with partial options' do
|
|
80
|
+
it "should be true if a field with the given partial options is on the page" do
|
|
81
|
+
@session.should have_select('Region', :with_options => ['Norway', 'Sweden'])
|
|
82
|
+
@session.should have_select('City', :with_options => ['London'])
|
|
83
|
+
end
|
|
119
84
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
end
|
|
85
|
+
it "should be false if a field with the given partial options is not on the page" do
|
|
86
|
+
@session.should_not have_select('Locale', :with_options => ['Uruguayan'])
|
|
87
|
+
@session.should_not have_select('Does not exist', :with_options => ['John'])
|
|
88
|
+
@session.should_not have_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
|
|
125
89
|
end
|
|
126
90
|
end
|
|
127
91
|
end
|
|
128
92
|
|
|
93
|
+
Capybara::SpecHelper.spec '#has_no_select?' do
|
|
94
|
+
before { @session.visit('/form') }
|
|
129
95
|
|
|
96
|
+
it "should be false if the field is on the page" do
|
|
97
|
+
@session.should_not have_no_select('Locale')
|
|
98
|
+
@session.should_not have_no_select('form_region')
|
|
99
|
+
@session.should_not have_no_select('Languages')
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should be true if the field is not on the page" do
|
|
103
|
+
@session.should have_no_select('Monkey')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
context 'with selected value' do
|
|
107
|
+
it "should be false if a field with the given value is on the page" do
|
|
108
|
+
@session.should_not have_no_select('form_locale', :selected => 'English')
|
|
109
|
+
@session.should_not have_no_select('Region', :selected => 'Norway')
|
|
110
|
+
@session.should_not have_no_select('Underwear', :selected => [
|
|
111
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
112
|
+
])
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "should be true if the given field is not on the page" do
|
|
116
|
+
@session.should have_no_select('Locale', :selected => 'Swedish')
|
|
117
|
+
@session.should have_no_select('Does not exist', :selected => 'John')
|
|
118
|
+
@session.should have_no_select('City', :selected => 'Not there')
|
|
119
|
+
@session.should have_no_select('Underwear', :selected => [
|
|
120
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
|
121
|
+
])
|
|
122
|
+
@session.should have_no_select('Underwear', :selected => [
|
|
123
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
124
|
+
])
|
|
125
|
+
@session.should have_no_select('Underwear', :selected => [
|
|
126
|
+
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
|
127
|
+
])
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "should be false after the given value is selected" do
|
|
131
|
+
@session.select('Swedish', :from => 'Locale')
|
|
132
|
+
@session.should_not have_no_select('Locale', :selected => 'Swedish')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "should be true after a different value is selected" do
|
|
136
|
+
@session.select('Swedish', :from => 'Locale')
|
|
137
|
+
@session.should have_no_select('Locale', :selected => 'English')
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "should be false after the given values are selected" do
|
|
141
|
+
@session.select('Boxers', :from => 'Underwear')
|
|
142
|
+
@session.should_not have_no_select('Underwear', :selected => [
|
|
143
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
144
|
+
])
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "should be true after one of the values is unselected" do
|
|
148
|
+
@session.unselect('Briefs', :from => 'Underwear')
|
|
149
|
+
@session.should have_no_select('Underwear', :selected => [
|
|
150
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
|
151
|
+
])
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
context 'with exact options' do
|
|
156
|
+
it "should be false if a field with the given options is on the page" do
|
|
157
|
+
@session.should_not have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "should be true if the given field is not on the page" do
|
|
161
|
+
@session.should have_no_select('Locale', :options => ['Swedish'])
|
|
162
|
+
@session.should have_no_select('Does not exist', :options => ['John'])
|
|
163
|
+
@session.should have_no_select('City', :options => ['London', 'Made up city'])
|
|
164
|
+
@session.should have_no_select('Region', :options => ['Norway', 'Sweden'])
|
|
165
|
+
@session.should have_no_select('Region', :options => ['Norway', 'Norway', 'Norway'])
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
context 'with partial options' do
|
|
170
|
+
it "should be false if a field with the given partial options is on the page" do
|
|
171
|
+
@session.should_not have_no_select('Region', :with_options => ['Norway', 'Sweden'])
|
|
172
|
+
@session.should_not have_no_select('City', :with_options => ['London'])
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
it "should be true if a field with the given partial options is not on the page" do
|
|
176
|
+
@session.should have_no_select('Locale', :with_options => ['Uruguayan'])
|
|
177
|
+
@session.should have_no_select('Does not exist', :with_options => ['John'])
|
|
178
|
+
@session.should have_no_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
@@ -1,129 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
Capybara::SpecHelper.spec '#has_selector?' do
|
|
2
|
+
before do
|
|
3
|
+
@session.visit('/with_html')
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
it "should be true if the given selector is on the page" do
|
|
7
|
+
@session.should have_selector(:xpath, "//p")
|
|
8
|
+
@session.should have_selector(:css, "p a#foo")
|
|
9
|
+
@session.should have_selector("//p[contains(.,'est')]")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should be false if the given selector is not on the page" do
|
|
13
|
+
@session.should_not have_selector(:xpath, "//abbr")
|
|
14
|
+
@session.should_not have_selector(:css, "p a#doesnotexist")
|
|
15
|
+
@session.should_not have_selector("//p[contains(.,'thisstringisnotonpage')]")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should use default selector" do
|
|
19
|
+
Capybara.default_selector = :css
|
|
20
|
+
@session.should_not have_selector("p a#doesnotexist")
|
|
21
|
+
@session.should have_selector("p a#foo")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should respect scopes" do
|
|
25
|
+
@session.within "//p[@id='first']" do
|
|
26
|
+
@session.should have_selector(".//a[@id='foo']")
|
|
27
|
+
@session.should_not have_selector(".//a[@id='red']")
|
|
5
28
|
end
|
|
29
|
+
end
|
|
6
30
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@session.should have_selector(
|
|
10
|
-
@session.should have_selector(:
|
|
11
|
-
@session.should have_selector("//p[contains(.,'est')]")
|
|
31
|
+
context "with count" do
|
|
32
|
+
it "should be true if the content is on the page the given number of times" do
|
|
33
|
+
@session.should have_selector("//p", :count => 3)
|
|
34
|
+
@session.should have_selector("//p//a[@id='foo']", :count => 1)
|
|
35
|
+
@session.should have_selector("//p[contains(.,'est')]", :count => 1)
|
|
12
36
|
end
|
|
13
37
|
|
|
14
|
-
it "should be false if the
|
|
15
|
-
@session.should_not have_selector(
|
|
16
|
-
@session.should_not have_selector(
|
|
17
|
-
@session.should_not have_selector(:
|
|
18
|
-
@session.should_not have_selector("//p[contains(.,'thisstringisnotonpage')]")
|
|
38
|
+
it "should be false if the content is on the page the given number of times" do
|
|
39
|
+
@session.should_not have_selector("//p", :count => 6)
|
|
40
|
+
@session.should_not have_selector("//p//a[@id='foo']", :count => 2)
|
|
41
|
+
@session.should_not have_selector("//p[contains(.,'est')]", :count => 5)
|
|
19
42
|
end
|
|
20
43
|
|
|
21
|
-
it "should
|
|
22
|
-
|
|
23
|
-
@session.should_not have_selector("p
|
|
24
|
-
@session.should have_selector("p a#foo")
|
|
44
|
+
it "should be false if the content isn't on the page at all" do
|
|
45
|
+
@session.should_not have_selector("//abbr", :count => 2)
|
|
46
|
+
@session.should_not have_selector("//p//a[@id='doesnotexist']", :count => 1)
|
|
25
47
|
end
|
|
48
|
+
end
|
|
26
49
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
50
|
+
context "with text" do
|
|
51
|
+
it "should discard all matches where the given string is not contained" do
|
|
52
|
+
@session.should have_selector("//p//a", :text => "Redirect", :count => 1)
|
|
53
|
+
@session.should_not have_selector("//p", :text => "Doesnotexist")
|
|
32
54
|
end
|
|
33
55
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@session.should have_selector("//p//a[@id='foo']", :count => 1)
|
|
38
|
-
@session.should have_selector("//p[contains(.,'est')]", :count => 1)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should be false if the content is on the page the given number of times" do
|
|
42
|
-
@session.should_not have_selector("//p", :count => 6)
|
|
43
|
-
@session.should_not have_selector("//p//a[@id='foo']", :count => 2)
|
|
44
|
-
@session.should_not have_selector("//p[contains(.,'est')]", :count => 5)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "should be false if the content isn't on the page at all" do
|
|
48
|
-
@session.should_not have_selector("//abbr", :count => 2)
|
|
49
|
-
@session.should_not have_selector("//p//a[@id='doesnotexist']", :count => 1)
|
|
50
|
-
end
|
|
56
|
+
it "should discard all matches where the given regexp is not matched" do
|
|
57
|
+
@session.should have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
|
|
58
|
+
@session.should_not have_selector("//p//a", :text => /Red$/)
|
|
51
59
|
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
52
62
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
end
|
|
63
|
+
Capybara::SpecHelper.spec '#has_no_selector?' do
|
|
64
|
+
before do
|
|
65
|
+
@session.visit('/with_html')
|
|
66
|
+
end
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
end
|
|
68
|
+
it "should be false if the given selector is on the page" do
|
|
69
|
+
@session.should_not have_no_selector(:xpath, "//p")
|
|
70
|
+
@session.should_not have_no_selector(:css, "p a#foo")
|
|
71
|
+
@session.should_not have_no_selector("//p[contains(.,'est')]")
|
|
64
72
|
end
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
it "should be true if the given selector is not on the page" do
|
|
75
|
+
@session.should have_no_selector(:xpath, "//abbr")
|
|
76
|
+
@session.should have_no_selector(:css, "p a#doesnotexist")
|
|
77
|
+
@session.should have_no_selector("//p[contains(.,'thisstringisnotonpage')]")
|
|
78
|
+
end
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
end
|
|
80
|
+
it "should use default selector" do
|
|
81
|
+
Capybara.default_selector = :css
|
|
82
|
+
@session.should have_no_selector("p a#doesnotexist")
|
|
83
|
+
@session.should_not have_no_selector("p a#foo")
|
|
84
|
+
end
|
|
77
85
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
@session.
|
|
81
|
-
@session.should have_no_selector(
|
|
82
|
-
@session.should have_no_selector("//p[contains(.,'thisstringisnotonpage')]")
|
|
86
|
+
it "should respect scopes" do
|
|
87
|
+
@session.within "//p[@id='first']" do
|
|
88
|
+
@session.should_not have_no_selector(".//a[@id='foo']")
|
|
89
|
+
@session.should have_no_selector(".//a[@id='red']")
|
|
83
90
|
end
|
|
91
|
+
end
|
|
84
92
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
@session.
|
|
88
|
-
@session.should_not have_no_selector("p
|
|
93
|
+
context "with count" do
|
|
94
|
+
it "should be false if the content is on the page the given number of times" do
|
|
95
|
+
@session.should_not have_no_selector("//p", :count => 3)
|
|
96
|
+
@session.should_not have_no_selector("//p//a[@id='foo']", :count => 1)
|
|
97
|
+
@session.should_not have_no_selector("//p[contains(.,'est')]", :count => 1)
|
|
89
98
|
end
|
|
90
99
|
|
|
91
|
-
it "should
|
|
92
|
-
@session.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
end
|
|
100
|
+
it "should be true if the content is on the page the wrong number of times" do
|
|
101
|
+
@session.should have_no_selector("//p", :count => 6)
|
|
102
|
+
@session.should have_no_selector("//p//a[@id='foo']", :count => 2)
|
|
103
|
+
@session.should have_no_selector("//p[contains(.,'est')]", :count => 5)
|
|
96
104
|
end
|
|
97
105
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
@session.should_not have_no_selector("//p//a[@id='foo']", :count => 1)
|
|
102
|
-
@session.should_not have_no_selector("//p[contains(.,'est')]", :count => 1)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it "should be true if the content is on the page the wrong number of times" do
|
|
106
|
-
@session.should have_no_selector("//p", :count => 6)
|
|
107
|
-
@session.should have_no_selector("//p//a[@id='foo']", :count => 2)
|
|
108
|
-
@session.should have_no_selector("//p[contains(.,'est')]", :count => 5)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "should be true if the content isn't on the page at all" do
|
|
112
|
-
@session.should have_no_selector("//abbr", :count => 2)
|
|
113
|
-
@session.should have_no_selector("//p//a[@id='doesnotexist']", :count => 1)
|
|
114
|
-
end
|
|
106
|
+
it "should be true if the content isn't on the page at all" do
|
|
107
|
+
@session.should have_no_selector("//abbr", :count => 2)
|
|
108
|
+
@session.should have_no_selector("//p//a[@id='doesnotexist']", :count => 1)
|
|
115
109
|
end
|
|
110
|
+
end
|
|
116
111
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
context "with text" do
|
|
113
|
+
it "should discard all matches where the given string is contained" do
|
|
114
|
+
@session.should_not have_no_selector("//p//a", :text => "Redirect", :count => 1)
|
|
115
|
+
@session.should have_no_selector("//p", :text => "Doesnotexist")
|
|
116
|
+
end
|
|
122
117
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
end
|
|
118
|
+
it "should discard all matches where the given regexp is matched" do
|
|
119
|
+
@session.should_not have_no_selector("//p//a", :text => /re[dab]i/i, :count => 1)
|
|
120
|
+
@session.should have_no_selector("//p//a", :text => /Red$/)
|
|
127
121
|
end
|
|
128
122
|
end
|
|
129
123
|
end
|
|
@@ -1,96 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
@session.visit('/tables')
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
it "should be true if the field is on the page" do
|
|
8
|
-
@session.should have_table('Deaths')
|
|
9
|
-
@session.should have_table('villain_table')
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should be false if the field is not on the page" do
|
|
13
|
-
@session.should_not have_table('Monkey')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context 'with rows' do
|
|
17
|
-
it "should be true if a table with the given rows is on the page" do
|
|
18
|
-
@session.should have_table('Ransom', :rows => [['2007', '$300', '$100']])
|
|
19
|
-
@session.should have_table('Deaths', :rows => [['2007', '66', '7'], ['2008', '123', '12']])
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should be true if the given rows are incomplete" do
|
|
23
|
-
@session.should have_table('Ransom', :rows => [['$300', '$100']])
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should be false if the given table is not on the page" do
|
|
27
|
-
@session.should_not have_table('Does not exist', :selected => 'John')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should be false if the given rows contain incorrect elements" do
|
|
31
|
-
@session.should_not have_table('Ransom', :rows => [['2007', '$1000000000', '$100']])
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should be false if the given rows are incorrectly ordered" do
|
|
35
|
-
@session.should_not have_table('Ransom', :rows => [['2007', '$100', '$300']])
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should be false if the only some of the given rows are correct" do
|
|
39
|
-
@session.should_not have_table('Deaths', :rows => [['2007', '66', '7'], ['2007', '99999999', '12']])
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "should be false if the given rows are out of order" do
|
|
43
|
-
@session.should_not have_table('Deaths', :rows => [['2007', '123', '12'], ['2007', '66', '7']])
|
|
44
|
-
end
|
|
45
|
-
end
|
|
1
|
+
Capybara::SpecHelper.spec '#has_table?' do
|
|
2
|
+
before do
|
|
3
|
+
@session.visit('/tables')
|
|
46
4
|
end
|
|
47
5
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
it "should be false if the field is on the page" do
|
|
54
|
-
@session.should_not have_no_table('Deaths')
|
|
55
|
-
@session.should_not have_no_table('villain_table')
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "should be true if the field is not on the page" do
|
|
59
|
-
@session.should have_no_table('Monkey')
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
context 'with rows' do
|
|
63
|
-
it "should be false if a table with the given rows is on the page" do
|
|
64
|
-
@session.should_not have_no_table('Ransom', :rows => [['2007', '$300', '$100']])
|
|
65
|
-
@session.should_not have_no_table('Deaths', :rows => [['2007', '66', '7'], ['2008', '123', '12']])
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should be false if the given rows are incomplete" do
|
|
69
|
-
@session.should_not have_no_table('Ransom', :rows => [['$300', '$100']])
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "should be true if the given table is not on the page" do
|
|
73
|
-
@session.should have_no_table('Does not exist', :selected => 'John')
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "should be true if the given rows contain incorrect elements" do
|
|
77
|
-
@session.should have_no_table('Ransom', :rows => [['2007', '$1000000000', '$100']])
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "should be true if the given rows are incorrectly ordered" do
|
|
81
|
-
@session.should have_no_table('Ransom', :rows => [['2007', '$100', '$300']])
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "should be true if the only some of the given rows are correct" do
|
|
85
|
-
@session.should have_no_table('Deaths', :rows => [['2007', '66', '7'], ['2007', '99999999', '12']])
|
|
86
|
-
end
|
|
6
|
+
it "should be true if the table is on the page" do
|
|
7
|
+
@session.should have_table('Villain')
|
|
8
|
+
@session.should have_table('villain_table')
|
|
9
|
+
@session.should have_table(:'villain_table')
|
|
10
|
+
end
|
|
87
11
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
end
|
|
12
|
+
it "should be false if the table is not on the page" do
|
|
13
|
+
@session.should_not have_table('Monkey')
|
|
92
14
|
end
|
|
93
15
|
end
|
|
94
16
|
|
|
17
|
+
Capybara::SpecHelper.spec '#has_no_table?' do
|
|
18
|
+
before do
|
|
19
|
+
@session.visit('/tables')
|
|
20
|
+
end
|
|
95
21
|
|
|
22
|
+
it "should be false if the table is on the page" do
|
|
23
|
+
@session.should_not have_no_table('Villain')
|
|
24
|
+
@session.should_not have_no_table('villain_table')
|
|
25
|
+
end
|
|
96
26
|
|
|
27
|
+
it "should be true if the table is not on the page" do
|
|
28
|
+
@session.should have_no_table('Monkey')
|
|
29
|
+
end
|
|
30
|
+
end
|