capybara 2.0.0.beta2 → 2.0.0.beta4
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 +30 -1
- data/README.md +52 -31
- data/lib/capybara.rb +1 -0
- data/lib/capybara/driver/base.rb +1 -1
- data/lib/capybara/driver/node.rb +1 -0
- data/lib/capybara/dsl.rb +12 -5
- data/lib/capybara/helpers.rb +33 -0
- data/lib/capybara/node/actions.rb +4 -2
- data/lib/capybara/node/base.rb +52 -1
- data/lib/capybara/node/element.rb +0 -12
- data/lib/capybara/node/finders.rb +1 -1
- data/lib/capybara/node/matchers.rb +57 -47
- data/lib/capybara/node/simple.rb +4 -0
- data/lib/capybara/query.rb +11 -11
- data/lib/capybara/rack_test/browser.rb +14 -15
- data/lib/capybara/rack_test/driver.rb +2 -2
- data/lib/capybara/rack_test/node.rb +15 -2
- data/lib/capybara/result.rb +7 -19
- data/lib/capybara/rspec.rb +7 -4
- data/lib/capybara/rspec/features.rb +4 -1
- data/lib/capybara/rspec/matchers.rb +8 -3
- data/lib/capybara/selector.rb +1 -2
- data/lib/capybara/selenium/driver.rb +2 -2
- data/lib/capybara/selenium/node.rb +9 -7
- data/lib/capybara/session.rb +47 -31
- data/lib/capybara/spec/fixtures/another_test_file.txt +1 -0
- data/lib/capybara/spec/public/test.js +1 -1
- data/lib/capybara/spec/session/all_spec.rb +60 -62
- data/lib/capybara/spec/session/assert_selector.rb +123 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +72 -58
- data/lib/capybara/spec/session/body_spec.rb +21 -0
- data/lib/capybara/spec/session/check_spec.rb +67 -50
- data/lib/capybara/spec/session/choose_spec.rb +32 -21
- data/lib/capybara/spec/session/click_button_spec.rb +261 -221
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +40 -30
- data/lib/capybara/spec/session/click_link_spec.rb +95 -81
- data/lib/capybara/spec/session/current_url_spec.rb +70 -60
- 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 +118 -92
- 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 +96 -91
- data/lib/capybara/spec/session/first_spec.rb +53 -55
- 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 +167 -169
- data/lib/capybara/spec/session/has_link_spec.rb +26 -29
- data/lib/capybara/spec/session/has_select_spec.rb +175 -176
- data/lib/capybara/spec/session/has_selector_spec.rb +94 -100
- data/lib/capybara/spec/session/has_table_spec.rb +22 -26
- data/lib/capybara/spec/session/has_text_spec.rb +159 -132
- 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 +172 -82
- 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 +8 -24
- data/lib/capybara/spec/session/select_spec.rb +100 -89
- data/lib/capybara/spec/session/source_spec.rb +12 -0
- data/lib/capybara/spec/session/text_spec.rb +15 -17
- data/lib/capybara/spec/session/uncheck_spec.rb +22 -17
- data/lib/capybara/spec/session/unselect_spec.rb +57 -52
- data/lib/capybara/spec/session/visit_spec.rb +58 -60
- data/lib/capybara/spec/session/within_frame_spec.rb +24 -26
- data/lib/capybara/spec/session/within_spec.rb +119 -121
- data/lib/capybara/spec/session/within_window_spec.rb +29 -31
- data/lib/capybara/spec/spec_helper.rb +84 -0
- data/lib/capybara/spec/test_app.rb +5 -3
- data/lib/capybara/spec/views/form.erb +1 -0
- data/lib/capybara/spec/views/with_html.erb +6 -1
- data/lib/capybara/spec/views/with_js.erb +1 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +2 -2
- data/spec/capybara_spec.rb +9 -0
- data/spec/dsl_spec.rb +22 -10
- data/spec/rack_test_spec.rb +28 -23
- data/spec/result_spec.rb +51 -0
- data/spec/rspec/features_spec.rb +19 -0
- data/spec/rspec/matchers_spec.rb +6 -0
- data/spec/rspec_spec.rb +1 -1
- data/spec/selenium_spec.rb +11 -25
- data/spec/server_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -46
- metadata +41 -98
- data/lib/capybara/spec/session.rb +0 -183
- data/lib/capybara/spec/session/javascript.rb +0 -290
- data/lib/capybara/util/save_and_open_page.rb +0 -45
- data/spec/save_and_open_page_spec.rb +0 -155
|
@@ -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,34 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
@session.visit('/tables')
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
it "should be true if the table is on the page" do
|
|
8
|
-
@session.should have_table('Villain')
|
|
9
|
-
@session.should have_table('villain_table')
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should be false if the table is not on the page" do
|
|
13
|
-
@session.should_not have_table('Monkey')
|
|
14
|
-
end
|
|
1
|
+
Capybara::SpecHelper.spec '#has_table?' do
|
|
2
|
+
before do
|
|
3
|
+
@session.visit('/tables')
|
|
15
4
|
end
|
|
16
5
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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
|
|
26
11
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
end
|
|
12
|
+
it "should be false if the table is not on the page" do
|
|
13
|
+
@session.should_not have_table('Monkey')
|
|
30
14
|
end
|
|
31
15
|
end
|
|
32
16
|
|
|
17
|
+
Capybara::SpecHelper.spec '#has_no_table?' do
|
|
18
|
+
before do
|
|
19
|
+
@session.visit('/tables')
|
|
20
|
+
end
|
|
33
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
|
|
34
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
|
|
@@ -1,168 +1,195 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Capybara::SpecHelper.spec '#has_text?' do
|
|
2
|
+
it "should be true if the given text is on the page at least once" do
|
|
3
|
+
@session.visit('/with_html')
|
|
4
|
+
@session.should have_text('est')
|
|
5
|
+
@session.should have_text('Lorem')
|
|
6
|
+
@session.should have_text('Redirect')
|
|
7
|
+
@session.should have_text(:'Redirect')
|
|
8
|
+
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
end
|
|
10
|
+
it "should be true if scoped to an element which has the text" do
|
|
11
|
+
@session.visit('/with_html')
|
|
12
|
+
@session.within("//a[@title='awesome title']") do
|
|
13
|
+
@session.should have_text('labore')
|
|
15
14
|
end
|
|
15
|
+
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end
|
|
17
|
+
it "should be false if scoped to an element which does not have the text" do
|
|
18
|
+
@session.visit('/with_html')
|
|
19
|
+
@session.within("//a[@title='awesome title']") do
|
|
20
|
+
@session.should_not have_text('monkey')
|
|
22
21
|
end
|
|
22
|
+
end
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
it "should ignore tags" do
|
|
25
|
+
@session.visit('/with_html')
|
|
26
|
+
@session.should_not have_text('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
|
|
27
|
+
@session.should have_text('exercitation ullamco laboris')
|
|
28
|
+
end
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
it "should ignore extra whitespace and newlines" do
|
|
31
|
+
@session.visit('/with_html')
|
|
32
|
+
@session.should have_text('text with whitespace')
|
|
33
|
+
end
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
35
|
+
it "should ignore whitespace and newlines in the search string" do
|
|
36
|
+
@session.visit('/with_html')
|
|
37
|
+
@session.should have_text("text with \n\n whitespace")
|
|
38
|
+
end
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
it "should be false if the given text is not on the page" do
|
|
41
|
+
@session.visit('/with_html')
|
|
42
|
+
@session.should_not have_text('xxxxyzzz')
|
|
43
|
+
@session.should_not have_text('monkey')
|
|
44
|
+
end
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
it 'should handle single quotes in the text' do
|
|
47
|
+
@session.visit('/with-quotes')
|
|
48
|
+
@session.should have_text("can't")
|
|
49
|
+
end
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
it 'should handle double quotes in the text' do
|
|
52
|
+
@session.visit('/with-quotes')
|
|
53
|
+
@session.should have_text(%q{"No," he said})
|
|
54
|
+
end
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
it 'should handle mixed single and double quotes in the text' do
|
|
57
|
+
@session.visit('/with-quotes')
|
|
58
|
+
@session.should have_text(%q{"you can't do that."})
|
|
59
|
+
end
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
end
|
|
61
|
+
it 'should be false if text is in the title tag in the head' do
|
|
62
|
+
@session.visit('/with_js')
|
|
63
|
+
@session.should_not have_text('with_js')
|
|
64
|
+
end
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
it 'should be false if text is inside a script tag in the body' do
|
|
67
|
+
@session.visit('/with_js')
|
|
68
|
+
@session.should_not have_text('a javascript comment')
|
|
69
|
+
@session.should_not have_text('aVar')
|
|
70
|
+
end
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
it "should be false if the given text is on the page but not visible" do
|
|
73
|
+
@session.visit('/with_html')
|
|
74
|
+
@session.should_not have_text('Inside element with hidden ancestor')
|
|
75
|
+
end
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
it "should be true if the text in the page matches given regexp" do
|
|
78
|
+
@session.visit('/with_html')
|
|
79
|
+
@session.should have_text(/Lorem/)
|
|
80
|
+
end
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
end
|
|
82
|
+
it "should be false if the text in the page doesn't match given regexp" do
|
|
83
|
+
@session.visit('/with_html')
|
|
84
|
+
@session.should_not have_text(/xxxxyzzz/)
|
|
86
85
|
end
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@session.should_not have_no_text('Lorem')
|
|
93
|
-
@session.should_not have_no_text('Redirect')
|
|
94
|
-
end
|
|
87
|
+
it "should escape any characters that would have special meaning in a regexp" do
|
|
88
|
+
@session.visit('/with_html')
|
|
89
|
+
@session.should_not have_text('.orem')
|
|
90
|
+
end
|
|
95
91
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
end
|
|
101
|
-
end
|
|
92
|
+
it "should accept non-string parameters" do
|
|
93
|
+
@session.visit('/with_html')
|
|
94
|
+
@session.should have_text(42)
|
|
95
|
+
end
|
|
102
96
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
it "should be true when passed nil" do
|
|
98
|
+
# Historical behavior; no particular reason other than compatibility.
|
|
99
|
+
@session.visit('/with_html')
|
|
100
|
+
@session.should have_text(nil)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should wait for text to appear", :requires => [:js] do
|
|
104
|
+
@session.visit('/with_js')
|
|
105
|
+
@session.click_link('Click me')
|
|
106
|
+
@session.should have_text("Has been clicked")
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
Capybara::SpecHelper.spec '#has_no_text?' do
|
|
111
|
+
it "should be false if the given text is on the page at least once" do
|
|
112
|
+
@session.visit('/with_html')
|
|
113
|
+
@session.should_not have_no_text('est')
|
|
114
|
+
@session.should_not have_no_text('Lorem')
|
|
115
|
+
@session.should_not have_no_text('Redirect')
|
|
116
|
+
end
|
|
109
117
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
@session.should_not have_no_text('
|
|
118
|
+
it "should be false if scoped to an element which has the text" do
|
|
119
|
+
@session.visit('/with_html')
|
|
120
|
+
@session.within("//a[@title='awesome title']") do
|
|
121
|
+
@session.should_not have_no_text('labore')
|
|
114
122
|
end
|
|
123
|
+
end
|
|
115
124
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
it "should be true if scoped to an element which does not have the text" do
|
|
126
|
+
@session.visit('/with_html')
|
|
127
|
+
@session.within("//a[@title='awesome title']") do
|
|
119
128
|
@session.should have_no_text('monkey')
|
|
120
129
|
end
|
|
130
|
+
end
|
|
121
131
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
it "should ignore tags" do
|
|
133
|
+
@session.visit('/with_html')
|
|
134
|
+
@session.should have_no_text('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
|
|
135
|
+
@session.should_not have_no_text('exercitation ullamco laboris')
|
|
136
|
+
end
|
|
126
137
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
it "should be true if the given text is not on the page" do
|
|
139
|
+
@session.visit('/with_html')
|
|
140
|
+
@session.should have_no_text('xxxxyzzz')
|
|
141
|
+
@session.should have_no_text('monkey')
|
|
142
|
+
end
|
|
131
143
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
it 'should handle single quotes in the text' do
|
|
145
|
+
@session.visit('/with-quotes')
|
|
146
|
+
@session.should_not have_no_text("can't")
|
|
147
|
+
end
|
|
136
148
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
it 'should handle double quotes in the text' do
|
|
150
|
+
@session.visit('/with-quotes')
|
|
151
|
+
@session.should_not have_no_text(%q{"No," he said})
|
|
152
|
+
end
|
|
141
153
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
end
|
|
154
|
+
it 'should handle mixed single and double quotes in the text' do
|
|
155
|
+
@session.visit('/with-quotes')
|
|
156
|
+
@session.should_not have_no_text(%q{"you can't do that."})
|
|
157
|
+
end
|
|
147
158
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
it 'should be true if text is in the title tag in the head' do
|
|
160
|
+
@session.visit('/with_js')
|
|
161
|
+
@session.should have_no_text('with_js')
|
|
162
|
+
end
|
|
152
163
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
it 'should be true if text is inside a script tag in the body' do
|
|
165
|
+
@session.visit('/with_js')
|
|
166
|
+
@session.should have_no_text('a javascript comment')
|
|
167
|
+
@session.should have_no_text('aVar')
|
|
168
|
+
end
|
|
157
169
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
it "should be true if the given text is on the page but not visible" do
|
|
171
|
+
@session.visit('/with_html')
|
|
172
|
+
@session.should have_no_text('Inside element with hidden ancestor')
|
|
173
|
+
end
|
|
162
174
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
175
|
+
it "should be true if the text in the page doesn't match given regexp" do
|
|
176
|
+
@session.visit('/with_html')
|
|
177
|
+
@session.should have_no_text(/xxxxyzzz/)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "should be false if the text in the page matches given regexp" do
|
|
181
|
+
@session.visit('/with_html')
|
|
182
|
+
@session.should_not have_no_text(/Lorem/)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "should escape any characters that would have special meaning in a regexp" do
|
|
186
|
+
@session.visit('/with_html')
|
|
187
|
+
@session.should have_no_text('.orem')
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should wait for text to disappear", :requires => [:js] do
|
|
191
|
+
@session.visit('/with_js')
|
|
192
|
+
@session.click_link('Click me')
|
|
193
|
+
@session.should have_no_text("I changed it")
|
|
167
194
|
end
|
|
168
195
|
end
|