Created
October 19, 2012 12:41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Case1 < TestCase | |
test id:1 do | |
description "bla" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestCase | |
class << self | |
@@depth = 0 | |
@@out = "" | |
def test(*args, &block) | |
method_missing(:test, args, block) | |
end | |
def method_missing(sym, *args, &block) | |
@@depth += 1 | |
@@out += "<#{sym}" | |
if args.size > 1 | |
data = args[0] | |
options = args[1] | |
else | |
if args[0].is_a? Hash | |
options = args[0] | |
data = nil | |
else | |
data = args[0] | |
options = {} | |
end | |
end | |
options.each_pair do |key,value| | |
@@out += " #{key}=#{value}" | |
end | |
@@out += ">" | |
if data | |
@@out += data | |
elsif block_given? | |
yield(block) | |
end | |
@@out += "</#{sym}>" | |
@@depth -= 1 | |
puts @@out if @@depth == 0 | |
end | |
end | |
def old | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment