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.
Files changed (93) hide show
  1. data/History.txt +30 -1
  2. data/README.md +52 -31
  3. data/lib/capybara.rb +1 -0
  4. data/lib/capybara/driver/base.rb +1 -1
  5. data/lib/capybara/driver/node.rb +1 -0
  6. data/lib/capybara/dsl.rb +12 -5
  7. data/lib/capybara/helpers.rb +33 -0
  8. data/lib/capybara/node/actions.rb +4 -2
  9. data/lib/capybara/node/base.rb +52 -1
  10. data/lib/capybara/node/element.rb +0 -12
  11. data/lib/capybara/node/finders.rb +1 -1
  12. data/lib/capybara/node/matchers.rb +57 -47
  13. data/lib/capybara/node/simple.rb +4 -0
  14. data/lib/capybara/query.rb +11 -11
  15. data/lib/capybara/rack_test/browser.rb +14 -15
  16. data/lib/capybara/rack_test/driver.rb +2 -2
  17. data/lib/capybara/rack_test/node.rb +15 -2
  18. data/lib/capybara/result.rb +7 -19
  19. data/lib/capybara/rspec.rb +7 -4
  20. data/lib/capybara/rspec/features.rb +4 -1
  21. data/lib/capybara/rspec/matchers.rb +8 -3
  22. data/lib/capybara/selector.rb +1 -2
  23. data/lib/capybara/selenium/driver.rb +2 -2
  24. data/lib/capybara/selenium/node.rb +9 -7
  25. data/lib/capybara/session.rb +47 -31
  26. data/lib/capybara/spec/fixtures/another_test_file.txt +1 -0
  27. data/lib/capybara/spec/public/test.js +1 -1
  28. data/lib/capybara/spec/session/all_spec.rb +60 -62
  29. data/lib/capybara/spec/session/assert_selector.rb +123 -0
  30. data/lib/capybara/spec/session/attach_file_spec.rb +72 -58
  31. data/lib/capybara/spec/session/body_spec.rb +21 -0
  32. data/lib/capybara/spec/session/check_spec.rb +67 -50
  33. data/lib/capybara/spec/session/choose_spec.rb +32 -21
  34. data/lib/capybara/spec/session/click_button_spec.rb +261 -221
  35. data/lib/capybara/spec/session/click_link_or_button_spec.rb +40 -30
  36. data/lib/capybara/spec/session/click_link_spec.rb +95 -81
  37. data/lib/capybara/spec/session/current_url_spec.rb +70 -60
  38. data/lib/capybara/spec/session/evaluate_script_spec.rb +6 -0
  39. data/lib/capybara/spec/session/execute_script_spec.rb +7 -0
  40. data/lib/capybara/spec/session/fill_in_spec.rb +118 -92
  41. data/lib/capybara/spec/session/find_button_spec.rb +16 -14
  42. data/lib/capybara/spec/session/find_by_id_spec.rb +16 -14
  43. data/lib/capybara/spec/session/find_field_spec.rb +23 -21
  44. data/lib/capybara/spec/session/find_link_spec.rb +15 -14
  45. data/lib/capybara/spec/session/find_spec.rb +96 -91
  46. data/lib/capybara/spec/session/first_spec.rb +53 -55
  47. data/lib/capybara/spec/session/has_button_spec.rb +22 -24
  48. data/lib/capybara/spec/session/has_css_spec.rb +190 -205
  49. data/lib/capybara/spec/session/has_field_spec.rb +167 -169
  50. data/lib/capybara/spec/session/has_link_spec.rb +26 -29
  51. data/lib/capybara/spec/session/has_select_spec.rb +175 -176
  52. data/lib/capybara/spec/session/has_selector_spec.rb +94 -100
  53. data/lib/capybara/spec/session/has_table_spec.rb +22 -26
  54. data/lib/capybara/spec/session/has_text_spec.rb +159 -132
  55. data/lib/capybara/spec/session/has_xpath_spec.rb +100 -96
  56. data/lib/capybara/spec/session/headers.rb +4 -17
  57. data/lib/capybara/spec/session/html_spec.rb +15 -0
  58. data/lib/capybara/spec/session/node_spec.rb +172 -82
  59. data/lib/capybara/spec/session/reset_session_spec.rb +42 -0
  60. data/lib/capybara/spec/session/response_code.rb +4 -17
  61. data/lib/capybara/spec/session/save_page_spec.rb +46 -0
  62. data/lib/capybara/spec/session/screenshot.rb +8 -24
  63. data/lib/capybara/spec/session/select_spec.rb +100 -89
  64. data/lib/capybara/spec/session/source_spec.rb +12 -0
  65. data/lib/capybara/spec/session/text_spec.rb +15 -17
  66. data/lib/capybara/spec/session/uncheck_spec.rb +22 -17
  67. data/lib/capybara/spec/session/unselect_spec.rb +57 -52
  68. data/lib/capybara/spec/session/visit_spec.rb +58 -60
  69. data/lib/capybara/spec/session/within_frame_spec.rb +24 -26
  70. data/lib/capybara/spec/session/within_spec.rb +119 -121
  71. data/lib/capybara/spec/session/within_window_spec.rb +29 -31
  72. data/lib/capybara/spec/spec_helper.rb +84 -0
  73. data/lib/capybara/spec/test_app.rb +5 -3
  74. data/lib/capybara/spec/views/form.erb +1 -0
  75. data/lib/capybara/spec/views/with_html.erb +6 -1
  76. data/lib/capybara/spec/views/with_js.erb +1 -0
  77. data/lib/capybara/version.rb +1 -1
  78. data/spec/basic_node_spec.rb +2 -2
  79. data/spec/capybara_spec.rb +9 -0
  80. data/spec/dsl_spec.rb +22 -10
  81. data/spec/rack_test_spec.rb +28 -23
  82. data/spec/result_spec.rb +51 -0
  83. data/spec/rspec/features_spec.rb +19 -0
  84. data/spec/rspec/matchers_spec.rb +6 -0
  85. data/spec/rspec_spec.rb +1 -1
  86. data/spec/selenium_spec.rb +11 -25
  87. data/spec/server_spec.rb +2 -2
  88. data/spec/spec_helper.rb +1 -46
  89. metadata +41 -98
  90. data/lib/capybara/spec/session.rb +0 -183
  91. data/lib/capybara/spec/session/javascript.rb +0 -290
  92. data/lib/capybara/util/save_and_open_page.rb +0 -45
  93. data/spec/save_and_open_page_spec.rb +0 -155
@@ -1,129 +1,123 @@
1
- shared_examples_for "has_selector" do
2
- describe '#has_selector?' do
3
- before do
4
- @session.visit('/with_html')
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
- it "should be true if the given selector is on the page" do
8
- @session.should have_selector(:xpath, "//p")
9
- @session.should have_selector(:css, "p a#foo")
10
- @session.should have_selector(:foo)
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 given selector is not on the page" do
15
- @session.should_not have_selector(:xpath, "//abbr")
16
- @session.should_not have_selector(:css, "p a#doesnotexist")
17
- @session.should_not have_selector(:doesnotexist)
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 use default selector" do
22
- Capybara.default_selector = :css
23
- @session.should_not have_selector("p a#doesnotexist")
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
- it "should respect scopes" do
28
- @session.within "//p[@id='first']" do
29
- @session.should have_selector(".//a[@id='foo']")
30
- @session.should_not have_selector(".//a[@id='red']")
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
- context "with count" do
35
- it "should be true if the content is on the page the given number of times" do
36
- @session.should have_selector("//p", :count => 3)
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
- context "with text" do
54
- it "should discard all matches where the given string is not contained" do
55
- @session.should have_selector("//p//a", :text => "Redirect", :count => 1)
56
- @session.should_not have_selector("//p", :text => "Doesnotexist")
57
- end
63
+ Capybara::SpecHelper.spec '#has_no_selector?' do
64
+ before do
65
+ @session.visit('/with_html')
66
+ end
58
67
 
59
- it "should discard all matches where the given regexp is not matched" do
60
- @session.should have_selector("//p//a", :text => /re[dab]i/i, :count => 1)
61
- @session.should_not have_selector("//p//a", :text => /Red$/)
62
- end
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
- describe '#has_no_selector?' do
67
- before do
68
- @session.visit('/with_html')
69
- end
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
- it "should be false if the given selector is on the page" do
72
- @session.should_not have_no_selector(:xpath, "//p")
73
- @session.should_not have_no_selector(:css, "p a#foo")
74
- @session.should_not have_no_selector(:foo)
75
- @session.should_not have_no_selector("//p[contains(.,'est')]")
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
- it "should be true if the given selector is not on the page" do
79
- @session.should have_no_selector(:xpath, "//abbr")
80
- @session.should have_no_selector(:css, "p a#doesnotexist")
81
- @session.should have_no_selector(:doesnotexist)
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
- it "should use default selector" do
86
- Capybara.default_selector = :css
87
- @session.should have_no_selector("p a#doesnotexist")
88
- @session.should_not have_no_selector("p a#foo")
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 respect scopes" do
92
- @session.within "//p[@id='first']" do
93
- @session.should_not have_no_selector(".//a[@id='foo']")
94
- @session.should have_no_selector(".//a[@id='red']")
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
- context "with count" do
99
- it "should be false if the content is on the page the given number of times" do
100
- @session.should_not have_no_selector("//p", :count => 3)
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
- context "with text" do
118
- it "should discard all matches where the given string is contained" do
119
- @session.should_not have_no_selector("//p//a", :text => "Redirect", :count => 1)
120
- @session.should have_no_selector("//p", :text => "Doesnotexist")
121
- end
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
- it "should discard all matches where the given regexp is matched" do
124
- @session.should_not have_no_selector("//p//a", :text => /re[dab]i/i, :count => 1)
125
- @session.should have_no_selector("//p//a", :text => /Red$/)
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
- shared_examples_for "has_table" do
2
- describe '#has_table?' do
3
- before do
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
- describe '#has_no_table?' do
18
- before do
19
- @session.visit('/tables')
20
- end
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
- it "should be true if the table is not on the page" do
28
- @session.should have_no_table('Monkey')
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
- shared_examples_for 'has_text' do
2
- describe '#has_text?' do
3
- it "should be true if the given text is on the page at least once" do
4
- @session.visit('/with_html')
5
- @session.should have_text('est')
6
- @session.should have_text('Lorem')
7
- @session.should have_text('Redirect')
8
- end
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
- 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')
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
- 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')
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
- 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
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
- it "should ignore extra whitespace and newlines" do
31
- @session.visit('/with_html')
32
- @session.should have_text('text with whitespace')
33
- end
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
- it "should be false if the given text is not on the page" do
36
- @session.visit('/with_html')
37
- @session.should_not have_text('xxxxyzzz')
38
- @session.should_not have_text('monkey')
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
- it 'should handle single quotes in the text' do
42
- @session.visit('/with-quotes')
43
- @session.should have_text("can't")
44
- end
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
- it 'should handle double quotes in the text' do
47
- @session.visit('/with-quotes')
48
- @session.should have_text(%q{"No," he said})
49
- end
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
- it 'should handle mixed single and double quotes in the text' do
52
- @session.visit('/with-quotes')
53
- @session.should have_text(%q{"you can't do that."})
54
- end
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
- it 'should be false if text is in the title tag in the head' do
57
- @session.visit('/with_js')
58
- @session.should_not have_text('with_js')
59
- end
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
- it 'should be false if text is inside a script tag in the body' do
62
- @session.visit('/with_js')
63
- @session.should_not have_text('a javascript comment')
64
- @session.should_not have_text('aVar')
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
- it "should be false if the given text is on the page but not visible" do
68
- @session.visit('/with_html')
69
- @session.should_not have_text('Inside element with hidden ancestor')
70
- end
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
- it "should be true if the text in the page matches given regexp" do
73
- @session.visit('/with_html')
74
- @session.should have_text(/Lorem/)
75
- end
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
- it "should be false if the text in the page doesn't match given regexp" do
78
- @session.visit('/with_html')
79
- @session.should_not have_text(/xxxxyzzz/)
80
- end
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
- it "should escape any characters that would have special meaning in a regexp" do
83
- @session.visit('/with_html')
84
- @session.should_not have_text('.orem')
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
- describe '#has_no_text?' do
89
- it "should be false if the given text is on the page at least once" do
90
- @session.visit('/with_html')
91
- @session.should_not have_no_text('est')
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
- it "should be false if scoped to an element which has the text" do
97
- @session.visit('/with_html')
98
- @session.within("//a[@title='awesome title']") do
99
- @session.should_not have_no_text('labore')
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
- it "should be true if scoped to an element which does not have the text" do
104
- @session.visit('/with_html')
105
- @session.within("//a[@title='awesome title']") do
106
- @session.should have_no_text('monkey')
107
- end
108
- end
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
- it "should ignore tags" do
111
- @session.visit('/with_html')
112
- @session.should have_no_text('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
113
- @session.should_not have_no_text('exercitation ullamco laboris')
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
- it "should be true if the given text is not on the page" do
117
- @session.visit('/with_html')
118
- @session.should have_no_text('xxxxyzzz')
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
- it 'should handle single quotes in the text' do
123
- @session.visit('/with-quotes')
124
- @session.should_not have_no_text("can't")
125
- end
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
- it 'should handle double quotes in the text' do
128
- @session.visit('/with-quotes')
129
- @session.should_not have_no_text(%q{"No," he said})
130
- end
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
- it 'should handle mixed single and double quotes in the text' do
133
- @session.visit('/with-quotes')
134
- @session.should_not have_no_text(%q{"you can't do that."})
135
- end
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
- it 'should be true if text is in the title tag in the head' do
138
- @session.visit('/with_js')
139
- @session.should have_no_text('with_js')
140
- end
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
- it 'should be true if text is inside a script tag in the body' do
143
- @session.visit('/with_js')
144
- @session.should have_no_text('a javascript comment')
145
- @session.should have_no_text('aVar')
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
- it "should be true if the given text is on the page but not visible" do
149
- @session.visit('/with_html')
150
- @session.should have_no_text('Inside element with hidden ancestor')
151
- end
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
- it "should be true if the text in the page doesn't match given regexp" do
154
- @session.visit('/with_html')
155
- @session.should have_no_text(/xxxxyzzz/)
156
- end
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
- it "should be false if the text in the page matches given regexp" do
159
- @session.visit('/with_html')
160
- @session.should_not have_no_text(/Lorem/)
161
- end
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
- it "should escape any characters that would have special meaning in a regexp" do
164
- @session.visit('/with_html')
165
- @session.should have_no_text('.orem')
166
- end
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