Commit 50277d03227dadfa232a7bf45f1a7792c5094c10
1 parent
89b238e2
Exists in
master
and in
22 other branches
ActionItem392: sharing useful assertions
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2045 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
12 additions
and
14 deletions
Show diff stats
test/test_helper.rb
| ... | ... | @@ -193,6 +193,18 @@ class Test::Unit::TestCase |
| 193 | 193 | assert !text.index('<'), "Text '#{text}' expected to be sanitized" |
| 194 | 194 | end |
| 195 | 195 | |
| 196 | + def assert_tag_in_string(text, options) | |
| 197 | + doc = HTML::Document.new(text, false, false) | |
| 198 | + tag = doc.find(options) | |
| 199 | + assert tag, "expected tag #{options.inspect}, but not found in #{text.inspect}" | |
| 200 | + end | |
| 201 | + | |
| 202 | + def assert_no_tag_in_string(text, options) | |
| 203 | + doc = HTML::Document.new(text, false, false) | |
| 204 | + tag = doc.find(options) | |
| 205 | + assert !tag, "expected no tag #{options.inspect}, but tag found in #{text.inspect}" | |
| 206 | + end | |
| 207 | + | |
| 196 | 208 | private |
| 197 | 209 | |
| 198 | 210 | def uses_host(name) | ... | ... |
test/unit/event_test.rb
| ... | ... | @@ -163,18 +163,4 @@ class EventTest < ActiveSupport::TestCase |
| 163 | 163 | assert_no_tag_in_string e.description, :tag => 'script' |
| 164 | 164 | end |
| 165 | 165 | |
| 166 | - protected | |
| 167 | - | |
| 168 | - def assert_tag_in_string(text, options) | |
| 169 | - doc = HTML::Document.new(text, false, false) | |
| 170 | - tag = doc.find(options) | |
| 171 | - assert tag, "expected tag #{options.inspect}, but not found in #{text.inspect}" | |
| 172 | - end | |
| 173 | - | |
| 174 | - def assert_no_tag_in_string(text, options) | |
| 175 | - doc = HTML::Document.new(text, false, false) | |
| 176 | - tag = doc.find(options) | |
| 177 | - assert !tag, "expected no tag #{options.inspect}, but tag found in #{text.inspect}" | |
| 178 | - end | |
| 179 | - | |
| 180 | 166 | end | ... | ... |