bbc-capybara 1.1.2

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 (107) hide show
  1. data/History.txt +325 -0
  2. data/License.txt +22 -0
  3. data/README.md +815 -0
  4. data/lib/capybara.rb +368 -0
  5. data/lib/capybara/cucumber.rb +25 -0
  6. data/lib/capybara/driver/base.rb +64 -0
  7. data/lib/capybara/driver/node.rb +74 -0
  8. data/lib/capybara/dsl.rb +50 -0
  9. data/lib/capybara/node/actions.rb +146 -0
  10. data/lib/capybara/node/base.rb +63 -0
  11. data/lib/capybara/node/document.rb +25 -0
  12. data/lib/capybara/node/element.rb +201 -0
  13. data/lib/capybara/node/finders.rb +154 -0
  14. data/lib/capybara/node/matchers.rb +442 -0
  15. data/lib/capybara/node/simple.rb +132 -0
  16. data/lib/capybara/query.rb +63 -0
  17. data/lib/capybara/rack_test/browser.rb +126 -0
  18. data/lib/capybara/rack_test/driver.rb +80 -0
  19. data/lib/capybara/rack_test/form.rb +80 -0
  20. data/lib/capybara/rack_test/node.rb +121 -0
  21. data/lib/capybara/rails.rb +17 -0
  22. data/lib/capybara/rspec.rb +26 -0
  23. data/lib/capybara/rspec/features.rb +22 -0
  24. data/lib/capybara/rspec/matchers.rb +152 -0
  25. data/lib/capybara/selector.rb +156 -0
  26. data/lib/capybara/selenium/driver.rb +169 -0
  27. data/lib/capybara/selenium/node.rb +91 -0
  28. data/lib/capybara/server.rb +87 -0
  29. data/lib/capybara/session.rb +322 -0
  30. data/lib/capybara/spec/driver.rb +329 -0
  31. data/lib/capybara/spec/fixtures/capybara.jpg +3 -0
  32. data/lib/capybara/spec/fixtures/test_file.txt +1 -0
  33. data/lib/capybara/spec/public/jquery-ui.js +791 -0
  34. data/lib/capybara/spec/public/jquery.js +9046 -0
  35. data/lib/capybara/spec/public/test.js +43 -0
  36. data/lib/capybara/spec/session.rb +148 -0
  37. data/lib/capybara/spec/session/all_spec.rb +78 -0
  38. data/lib/capybara/spec/session/attach_file_spec.rb +76 -0
  39. data/lib/capybara/spec/session/check_spec.rb +68 -0
  40. data/lib/capybara/spec/session/choose_spec.rb +29 -0
  41. data/lib/capybara/spec/session/click_button_spec.rb +305 -0
  42. data/lib/capybara/spec/session/click_link_or_button_spec.rb +37 -0
  43. data/lib/capybara/spec/session/click_link_spec.rb +120 -0
  44. data/lib/capybara/spec/session/current_url_spec.rb +83 -0
  45. data/lib/capybara/spec/session/fill_in_spec.rb +127 -0
  46. data/lib/capybara/spec/session/find_button_spec.rb +18 -0
  47. data/lib/capybara/spec/session/find_by_id_spec.rb +18 -0
  48. data/lib/capybara/spec/session/find_field_spec.rb +26 -0
  49. data/lib/capybara/spec/session/find_link_spec.rb +19 -0
  50. data/lib/capybara/spec/session/find_spec.rb +168 -0
  51. data/lib/capybara/spec/session/first_spec.rb +105 -0
  52. data/lib/capybara/spec/session/has_button_spec.rb +32 -0
  53. data/lib/capybara/spec/session/has_css_spec.rb +243 -0
  54. data/lib/capybara/spec/session/has_field_spec.rb +192 -0
  55. data/lib/capybara/spec/session/has_link_spec.rb +37 -0
  56. data/lib/capybara/spec/session/has_select_spec.rb +129 -0
  57. data/lib/capybara/spec/session/has_selector_spec.rb +129 -0
  58. data/lib/capybara/spec/session/has_table_spec.rb +34 -0
  59. data/lib/capybara/spec/session/has_text_spec.rb +138 -0
  60. data/lib/capybara/spec/session/has_xpath_spec.rb +123 -0
  61. data/lib/capybara/spec/session/headers.rb +19 -0
  62. data/lib/capybara/spec/session/javascript.rb +312 -0
  63. data/lib/capybara/spec/session/response_code.rb +19 -0
  64. data/lib/capybara/spec/session/select_spec.rb +119 -0
  65. data/lib/capybara/spec/session/text_spec.rb +24 -0
  66. data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
  67. data/lib/capybara/spec/session/unselect_spec.rb +67 -0
  68. data/lib/capybara/spec/session/within_spec.rb +178 -0
  69. data/lib/capybara/spec/test_app.rb +156 -0
  70. data/lib/capybara/spec/views/buttons.erb +4 -0
  71. data/lib/capybara/spec/views/fieldsets.erb +29 -0
  72. data/lib/capybara/spec/views/form.erb +366 -0
  73. data/lib/capybara/spec/views/frame_one.erb +8 -0
  74. data/lib/capybara/spec/views/frame_two.erb +8 -0
  75. data/lib/capybara/spec/views/header_links.erb +7 -0
  76. data/lib/capybara/spec/views/host_links.erb +12 -0
  77. data/lib/capybara/spec/views/popup_one.erb +8 -0
  78. data/lib/capybara/spec/views/popup_two.erb +8 -0
  79. data/lib/capybara/spec/views/postback.erb +13 -0
  80. data/lib/capybara/spec/views/tables.erb +62 -0
  81. data/lib/capybara/spec/views/with_html.erb +75 -0
  82. data/lib/capybara/spec/views/with_html_entities.erb +1 -0
  83. data/lib/capybara/spec/views/with_js.erb +53 -0
  84. data/lib/capybara/spec/views/with_scope.erb +36 -0
  85. data/lib/capybara/spec/views/with_simple_html.erb +1 -0
  86. data/lib/capybara/spec/views/within_frames.erb +10 -0
  87. data/lib/capybara/spec/views/within_popups.erb +25 -0
  88. data/lib/capybara/util/save_and_open_page.rb +45 -0
  89. data/lib/capybara/util/timeout.rb +27 -0
  90. data/lib/capybara/version.rb +3 -0
  91. data/spec/basic_node_spec.rb +89 -0
  92. data/spec/capybara_spec.rb +46 -0
  93. data/spec/driver/rack_test_driver_spec.rb +90 -0
  94. data/spec/driver/selenium_driver_spec.rb +55 -0
  95. data/spec/dsl_spec.rb +255 -0
  96. data/spec/fixtures/selenium_driver_rspec_failure.rb +8 -0
  97. data/spec/fixtures/selenium_driver_rspec_success.rb +8 -0
  98. data/spec/rspec/features_spec.rb +43 -0
  99. data/spec/rspec/matchers_spec.rb +564 -0
  100. data/spec/rspec_spec.rb +51 -0
  101. data/spec/save_and_open_page_spec.rb +155 -0
  102. data/spec/server_spec.rb +74 -0
  103. data/spec/session/rack_test_session_spec.rb +61 -0
  104. data/spec/session/selenium_session_spec.rb +26 -0
  105. data/spec/spec_helper.rb +31 -0
  106. data/spec/timeout_spec.rb +28 -0
  107. metadata +297 -0
@@ -0,0 +1,37 @@
1
+ shared_examples_for "has_link" do
2
+
3
+ describe '#has_link?' do
4
+ before do
5
+ @session.visit('/with_html')
6
+ end
7
+
8
+ it "should be true if the given link is on the page" do
9
+ @session.should have_link('foo')
10
+ @session.should have_link('awesome title')
11
+ @session.should have_link('A link', :href => '/with_simple_html')
12
+ end
13
+
14
+ it "should be false if the given link is not on the page" do
15
+ @session.should_not have_link('monkey')
16
+ @session.should_not have_link('A link', :href => '/non-existant-href')
17
+ end
18
+ end
19
+
20
+ describe '#has_no_link?' do
21
+ before do
22
+ @session.visit('/with_html')
23
+ end
24
+
25
+ it "should be false if the given link is on the page" do
26
+ @session.should_not have_no_link('foo')
27
+ @session.should_not have_no_link('awesome title')
28
+ @session.should_not have_no_link('A link', :href => '/with_simple_html')
29
+ end
30
+
31
+ it "should be true if the given link is not on the page" do
32
+ @session.should have_no_link('monkey')
33
+ @session.should have_no_link('A link', :href => '/non-existant-href')
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,129 @@
1
+ shared_examples_for "has_select" do
2
+ describe '#has_select?' do
3
+ before { @session.visit('/form') }
4
+
5
+ it "should be true if the field is on the page" do
6
+ @session.should have_select('Locale')
7
+ @session.should have_select('form_region')
8
+ @session.should have_select('Languages')
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
63
+ end
64
+
65
+ describe '#has_no_select?' do
66
+ before { @session.visit('/form') }
67
+
68
+ it "should be false if the field is on the page" do
69
+ @session.should_not have_no_select('Locale')
70
+ @session.should_not have_no_select('form_region')
71
+ @session.should_not have_no_select('Languages')
72
+ end
73
+
74
+ it "should be true if the field is not on the page" do
75
+ @session.should have_no_select('Monkey')
76
+ end
77
+
78
+ context 'with selected value' do
79
+ it "should be false if a field with the given value is on the page" do
80
+ @session.should_not have_no_select('form_locale', :selected => 'English')
81
+ @session.should_not have_no_select('Region', :selected => 'Norway')
82
+ @session.should_not have_no_select('Underwear', :selected => ['Briefs', 'Commando'])
83
+ end
84
+
85
+ it "should be true if the given field is not on the page" do
86
+ @session.should have_no_select('Locale', :selected => 'Swedish')
87
+ @session.should have_no_select('Does not exist', :selected => 'John')
88
+ @session.should have_no_select('City', :selected => 'Not there')
89
+ @session.should have_no_select('Underwear', :selected => ['Briefs', 'Nonexistant'])
90
+ @session.should have_no_select('Underwear', :selected => ['Briefs', 'Boxers'])
91
+ end
92
+
93
+ it "should be false after the given value is selected" do
94
+ @session.select('Swedish', :from => 'Locale')
95
+ @session.should_not have_no_select('Locale', :selected => 'Swedish')
96
+ end
97
+
98
+ it "should be true after a different value is selected" do
99
+ @session.select('Swedish', :from => 'Locale')
100
+ @session.should have_no_select('Locale', :selected => 'English')
101
+ end
102
+
103
+ it "should be false after the given values are selected" do
104
+ @session.select('Boxers', :from => 'Underwear')
105
+ @session.should_not have_no_select('Underwear', :selected => ['Briefs', 'Boxers', 'Commando'])
106
+ end
107
+
108
+ it "should be true after one of the values is unselected" do
109
+ @session.unselect('Briefs', :from => 'Underwear')
110
+ @session.should have_no_select('Underwear', :selected => ['Briefs', 'Commando'])
111
+ end
112
+ end
113
+
114
+ context 'with options' do
115
+ it "should be false if a field with the given options is on the page" do
116
+ @session.should_not have_no_select('form_locale', :options => ['English'])
117
+ @session.should_not have_no_select('Region', :options => ['Norway', 'Sweden'])
118
+ end
119
+
120
+ it "should be true if the given field is not on the page" do
121
+ @session.should have_no_select('Locale', :options => ['Not there'])
122
+ @session.should have_no_select('Does not exist', :options => ['John'])
123
+ @session.should have_no_select('City', :options => ['London', 'Made up city'])
124
+ end
125
+ end
126
+ end
127
+ end
128
+
129
+
@@ -0,0 +1,129 @@
1
+ shared_examples_for "has_selector" do
2
+ describe '#has_selector?' do
3
+ before do
4
+ @session.visit('/with_html')
5
+ end
6
+
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')]")
12
+ end
13
+
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')]")
19
+ end
20
+
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")
25
+ end
26
+
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
32
+ end
33
+
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
51
+ end
52
+
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
58
+
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
64
+ end
65
+
66
+ describe '#has_no_selector?' do
67
+ before do
68
+ @session.visit('/with_html')
69
+ end
70
+
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
77
+
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')]")
83
+ end
84
+
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")
89
+ end
90
+
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
96
+ end
97
+
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
115
+ end
116
+
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
122
+
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
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,34 @@
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
15
+ end
16
+
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
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
31
+ end
32
+
33
+
34
+
@@ -0,0 +1,138 @@
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
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
15
+ end
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
22
+ end
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
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
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
40
+
41
+ it 'should handle single quotes in the text' do
42
+ @session.visit('/with-quotes')
43
+ @session.should have_text("can't")
44
+ end
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
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
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
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
66
+
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
71
+ end
72
+
73
+ describe '#has_no_text?' do
74
+ it "should be false if the given text is on the page at least once" do
75
+ @session.visit('/with_html')
76
+ @session.should_not have_no_text('est')
77
+ @session.should_not have_no_text('Lorem')
78
+ @session.should_not have_no_text('Redirect')
79
+ end
80
+
81
+ it "should be false if scoped to an element which has the text" do
82
+ @session.visit('/with_html')
83
+ @session.within("//a[@title='awesome title']") do
84
+ @session.should_not have_no_text('labore')
85
+ end
86
+ end
87
+
88
+ it "should be true if scoped to an element which does not have the text" do
89
+ @session.visit('/with_html')
90
+ @session.within("//a[@title='awesome title']") do
91
+ @session.should have_no_text('monkey')
92
+ end
93
+ end
94
+
95
+ it "should ignore tags" do
96
+ @session.visit('/with_html')
97
+ @session.should have_no_text('exercitation <a href="/foo" id="foo">ullamco</a> laboris')
98
+ @session.should_not have_no_text('exercitation ullamco laboris')
99
+ end
100
+
101
+ it "should be true if the given text is not on the page" do
102
+ @session.visit('/with_html')
103
+ @session.should have_no_text('xxxxyzzz')
104
+ @session.should have_no_text('monkey')
105
+ end
106
+
107
+ it 'should handle single quotes in the text' do
108
+ @session.visit('/with-quotes')
109
+ @session.should_not have_no_text("can't")
110
+ end
111
+
112
+ it 'should handle double quotes in the text' do
113
+ @session.visit('/with-quotes')
114
+ @session.should_not have_no_text(%q{"No," he said})
115
+ end
116
+
117
+ it 'should handle mixed single and double quotes in the text' do
118
+ @session.visit('/with-quotes')
119
+ @session.should_not have_no_text(%q{"you can't do that."})
120
+ end
121
+
122
+ it 'should be true if text is in the title tag in the head' do
123
+ @session.visit('/with_js')
124
+ @session.should have_no_text('with_js')
125
+ end
126
+
127
+ it 'should be true if text is inside a script tag in the body' do
128
+ @session.visit('/with_js')
129
+ @session.should have_no_text('a javascript comment')
130
+ @session.should have_no_text('aVar')
131
+ end
132
+
133
+ it "should be true if the given text is on the page but not visible" do
134
+ @session.visit('/with_html')
135
+ @session.should have_no_text('Inside element with hidden ancestor')
136
+ end
137
+ end
138
+ end