@@ -36,147 +36,183 @@ def initialize(content_type, body)
36
36
end
37
37
38
38
def test_assert_tag_tag
39
- # there is a 'form' tag
40
- assert_tag tag : 'form'
41
- # there is not an 'hr' tag
42
- assert_no_tag tag : 'hr'
39
+ assert_deprecated do
40
+ # there is a 'form' tag
41
+ assert_tag tag : 'form'
42
+ # there is not an 'hr' tag
43
+ assert_no_tag tag : 'hr'
44
+ end
43
45
end
44
46
45
47
def test_assert_tag_attributes
46
- # there is a tag with an 'id' of 'bar'
47
- assert_tag attributes : { id : "bar" }
48
- # there is no tag with a 'name' of 'baz'
49
- assert_no_tag attributes : { name : "baz" }
48
+ assert_deprecated do
49
+ # there is a tag with an 'id' of 'bar'
50
+ assert_tag attributes : { id : "bar" }
51
+ # there is no tag with a 'name' of 'baz'
52
+ assert_no_tag attributes : { name : "baz" }
53
+ end
50
54
end
51
55
52
56
def test_assert_tag_parent
53
- # there is a tag with a parent 'form' tag
54
- assert_tag parent : { tag : "form" }
55
- # there is no tag with a parent of 'input'
56
- assert_no_tag parent : { tag : "input" }
57
+ assert_deprecated do
58
+ # there is a tag with a parent 'form' tag
59
+ assert_tag parent : { tag : "form" }
60
+ # there is no tag with a parent of 'input'
61
+ assert_no_tag parent : { tag : "input" }
62
+ end
57
63
end
58
64
59
65
def test_assert_tag_child
60
- # there is a tag with a child 'input' tag
61
- assert_tag child : { tag : "input" }
62
- # there is no tag with a child 'strong' tag
63
- assert_no_tag child : { tag : "strong" }
66
+ assert_deprecated do
67
+ # there is a tag with a child 'input' tag
68
+ assert_tag child : { tag : "input" }
69
+ # there is no tag with a child 'strong' tag
70
+ assert_no_tag child : { tag : "strong" }
71
+ end
64
72
end
65
73
66
74
def test_assert_tag_ancestor
67
- # there is a 'li' tag with an ancestor having an id of 'foo'
68
- assert_tag ancestor : { attributes : { id : "foo" } } , tag : "li"
69
- # there is no tag of any kind with an ancestor having an href matching 'foo'
70
- assert_no_tag ancestor : { attributes : { href : /foo/ } }
75
+ assert_deprecated do
76
+ # there is a 'li' tag with an ancestor having an id of 'foo'
77
+ assert_tag ancestor : { attributes : { id : "foo" } } , tag : "li"
78
+ # there is no tag of any kind with an ancestor having an href matching 'foo'
79
+ assert_no_tag ancestor : { attributes : { href : /foo/ } }
80
+ end
71
81
end
72
82
73
83
def test_assert_tag_descendant
74
- # there is a tag with a descendant 'li' tag
75
- assert_tag descendant : { tag : "li" }
76
- # there is no tag with a descendant 'html' tag
77
- assert_no_tag descendant : { tag : "html" }
84
+ assert_deprecated do
85
+ # there is a tag with a descendant 'li' tag
86
+ assert_tag descendant : { tag : "li" }
87
+ # there is no tag with a descendant 'html' tag
88
+ assert_no_tag descendant : { tag : "html" }
89
+ end
78
90
end
79
91
80
92
def test_assert_tag_sibling
81
- # there is a tag with a sibling of class 'item'
82
- assert_tag sibling : { attributes : { class : "item" } }
83
- # there is no tag with a sibling 'ul' tag
84
- assert_no_tag sibling : { tag : "ul" }
93
+ assert_deprecated do
94
+ # there is a tag with a sibling of class 'item'
95
+ assert_tag sibling : { attributes : { class : "item" } }
96
+ # there is no tag with a sibling 'ul' tag
97
+ assert_no_tag sibling : { tag : "ul" }
98
+ end
85
99
end
86
100
87
101
def test_assert_tag_after
88
- # there is a tag following a sibling 'div' tag
89
- assert_tag after : { tag : "div" }
90
- # there is no tag following a sibling tag with id 'bar'
91
- assert_no_tag after : { attributes : { id : "bar" } }
102
+ assert_deprecated do
103
+ # there is a tag following a sibling 'div' tag
104
+ assert_tag after : { tag : "div" }
105
+ # there is no tag following a sibling tag with id 'bar'
106
+ assert_no_tag after : { attributes : { id : "bar" } }
107
+ end
92
108
end
93
109
94
110
def test_assert_tag_before
95
- # there is a tag preceding a tag with id 'bar'
96
- assert_tag before : { attributes : { id : "bar" } }
97
- # there is no tag preceding a 'form' tag
98
- assert_no_tag before : { tag : "form" }
111
+ assert_deprecated do
112
+ # there is a tag preceding a tag with id 'bar'
113
+ assert_tag before : { attributes : { id : "bar" } }
114
+ # there is no tag preceding a 'form' tag
115
+ assert_no_tag before : { tag : "form" }
116
+ end
99
117
end
100
118
101
119
def test_assert_tag_children_count
102
- # there is a tag with 2 children
103
- assert_tag children : { count : 2 }
104
- # in particular, there is a <ul> tag with two children (a nameless pair of <li>s)
105
- assert_tag tag : 'ul' , children : { count : 2 }
106
- # there is no tag with 4 children
107
- assert_no_tag children : { count : 4 }
120
+ assert_deprecated do
121
+ # there is a tag with 2 children
122
+ assert_tag children : { count : 2 }
123
+ # in particular, there is a <ul> tag with two children (a nameless pair of <li>s)
124
+ assert_tag tag : 'ul' , children : { count : 2 }
125
+ # there is no tag with 4 children
126
+ assert_no_tag children : { count : 4 }
127
+ end
108
128
end
109
129
110
130
def test_assert_tag_children_less_than
111
- # there is a tag with less than 5 children
112
- assert_tag children : { less_than : 5 }
113
- # there is no 'ul' tag with less than 2 children
114
- assert_no_tag children : { less_than : 2 } , tag : "ul"
131
+ assert_deprecated do
132
+ # there is a tag with less than 5 children
133
+ assert_tag children : { less_than : 5 }
134
+ # there is no 'ul' tag with less than 2 children
135
+ assert_no_tag children : { less_than : 2 } , tag : "ul"
136
+ end
115
137
end
116
138
117
139
def test_assert_tag_children_greater_than
118
- # there is a 'body' tag with more than 1 children
119
- assert_tag children : { greater_than : 1 } , tag : "body"
120
- # there is no tag with more than 10 children
121
- assert_no_tag children : { greater_than : 10 }
140
+ assert_deprecated do
141
+ # there is a 'body' tag with more than 1 children
142
+ assert_tag children : { greater_than : 1 } , tag : "body"
143
+ # there is no tag with more than 10 children
144
+ assert_no_tag children : { greater_than : 10 }
145
+ end
122
146
end
123
147
124
148
def test_assert_tag_children_only
125
- # there is a tag containing only one child with an id of 'foo'
126
- assert_tag children : { count : 1 ,
127
- only : { attributes : { id : "foo" } } }
128
- # there is no tag containing only one 'li' child
129
- assert_no_tag children : { count : 1 , only : { tag : "li" } }
149
+ assert_deprecated do
150
+ # there is a tag containing only one child with an id of 'foo'
151
+ assert_tag children : { count : 1 ,
152
+ only : { attributes : { id : "foo" } } }
153
+ # there is no tag containing only one 'li' child
154
+ assert_no_tag children : { count : 1 , only : { tag : "li" } }
155
+ end
130
156
end
131
157
132
158
def test_assert_tag_content
133
- # the output contains the string "Name"
134
- assert_tag content : /Name/
135
- # the output does not contain the string "test"
136
- assert_no_tag content : /test/
159
+ assert_deprecated do
160
+ # the output contains the string "Name"
161
+ assert_tag content : /Name/
162
+ # the output does not contain the string "test"
163
+ assert_no_tag content : /test/
164
+ end
137
165
end
138
166
139
167
def test_assert_tag_multiple
140
- # there is a 'div', id='bar', with an immediate child whose 'action'
141
- # attribute matches the regexp /somewhere/.
142
- assert_tag tag : "div" , attributes : { id : "bar" } ,
143
- child : { attributes : { action : /somewhere/ } }
144
-
145
- # there is no 'div', id='foo', with a 'ul' child with more than
146
- # 2 "li" children.
147
- assert_no_tag tag : "div" , attributes : { id : "foo" } ,
148
- child : { tag : "ul" ,
149
- children : { greater_than : 2 , only : { tag : "li" } } }
168
+ assert_deprecated do
169
+ # there is a 'div', id='bar', with an immediate child whose 'action'
170
+ # attribute matches the regexp /somewhere/.
171
+ assert_tag tag : "div" , attributes : { id : "bar" } ,
172
+ child : { attributes : { action : /somewhere/ } }
173
+
174
+ # there is no 'div', id='foo', with a 'ul' child with more than
175
+ # 2 "li" children.
176
+ assert_no_tag tag : "div" , attributes : { id : "foo" } ,
177
+ child : { tag : "ul" ,
178
+ children : { greater_than : 2 , only : { tag : "li" } } }
179
+ end
150
180
end
151
181
152
182
def test_assert_tag_children_without_content
153
- # there is a form tag with an 'input' child which is a self closing tag
154
- assert_tag tag : "form" ,
155
- children : { count : 1 ,
156
- only : { tag : "input" } }
157
-
158
- # the body tag has an 'a' child which in turn has an 'img' child
159
- assert_tag tag : "body" ,
160
- children : { count : 1 ,
161
- only : { tag : "a" ,
183
+ assert_deprecated do
184
+ # there is a form tag with an 'input' child which is a self closing tag
185
+ assert_tag tag : "form" ,
186
+ children : { count : 1 ,
187
+ only : { tag : "input" } }
188
+
189
+ # the body tag has an 'a' child which in turn has an 'img' child
190
+ assert_tag tag : "body" ,
162
191
children : { count : 1 ,
163
- only : { tag : "img" } } } }
192
+ only : { tag : "a" ,
193
+ children : { count : 1 ,
194
+ only : { tag : "img" } } } }
195
+ end
164
196
end
165
197
166
198
def test_assert_tag_attribute_matching
167
- @response . body = '<input type="text" name="my_name">'
168
- assert_tag tag : 'input' ,
169
- attributes : { name : /my/ , type : 'text' }
170
- assert_no_tag tag : 'input' ,
171
- attributes : { name : 'my' , type : 'text' }
172
- assert_no_tag tag : 'input' ,
173
- attributes : { name : /^my$/ , type : 'text' }
199
+ assert_deprecated do
200
+ @response . body = '<input type="text" name="my_name">'
201
+ assert_tag tag : 'input' ,
202
+ attributes : { name : /my/ , type : 'text' }
203
+ assert_no_tag tag : 'input' ,
204
+ attributes : { name : 'my' , type : 'text' }
205
+ assert_no_tag tag : 'input' ,
206
+ attributes : { name : /^my$/ , type : 'text' }
207
+ end
174
208
end
175
209
176
210
def test_assert_tag_content_matching
177
- @response . body = "<p>hello world</p>"
178
- assert_tag tag : "p" , content : "hello world"
179
- assert_tag tag : "p" , content : /hello/
180
- assert_no_tag tag : "p" , content : "hello"
211
+ assert_deprecated do
212
+ @response . body = "<p>hello world</p>"
213
+ assert_tag tag : "p" , content : "hello world"
214
+ assert_tag tag : "p" , content : /hello/
215
+ assert_no_tag tag : "p" , content : "hello"
216
+ end
181
217
end
182
- end
218
+ end
0 commit comments