Commit 8c27090013ff4e7c4984a7dbdc33f3c8dfa72235
1 parent
43039251
Exists in
staging
and in
42 other branches
ActionItem8: including a 'should' in test_helper
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@431 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
13 additions
and
0 deletions
Show diff stats
test/test_helper.rb
| ... | ... | @@ -35,6 +35,19 @@ class Test::Unit::TestCase |
| 35 | 35 | end |
| 36 | 36 | end |
| 37 | 37 | |
| 38 | + def self.should(name, &block) | |
| 39 | + @shoulds ||= [] | |
| 40 | + | |
| 41 | + destname = 'test_should_' + name.gsub(/[^a-zA-z0-9]+/, '_') | |
| 42 | + if @shoulds.include?(destname) | |
| 43 | + raise "there is already a test named \"#{destname}\"" | |
| 44 | + end | |
| 45 | + | |
| 46 | + @shoulds << destname | |
| 47 | + self.send(:define_method, destname, &block) | |
| 48 | + | |
| 49 | + end | |
| 50 | + | |
| 38 | 51 | private |
| 39 | 52 | |
| 40 | 53 | def uses_host(name) | ... | ... |