Sha256: dd40a84b5ad68e24919caadc7a846cbc39ae9916c15b2dbb8c9f64038a21b680
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module TestUtil module Transformer class TestCase < StructX member :string member :expected end class TestCaseEq < StructX member :string member :expected end def spec(name, parser, context, &b) testcases = Array.new def testcases.tc(obj) case obj when Hash obj.each do |key, val| push(TestCaseEq.new(key, val)) end else push(TestCaseEq.new(obj, yield)) end end def testcases.transform(obj, &b) push(TestCase.new(obj, b)) end testcases.instance_eval(&b) context.describe name do testcases.each do |tc| it "should get %s:%s%s" % [name, tc.string.include?("\n") ? "\n" : " ", tc.string.chomp] do res = DocumentTransformer.new.apply( DocumentParser.new.send(parser).parse(tc.string) ) case tc when TestCaseEq res.should == tc.expected when TestCase tc.expected.call(res) end end end end end module_function :spec end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pione-0.2.2 | test/test-util/transformer.rb |