Sha256: 13f0d94c41e9b663717d73d2659136056104ac28e6c2d1380668ea2b77d7bb24
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
module ExampleTest module ClassMethods attr_accessor :latest_test_class attr_accessor :latest_test_case end extend ClassMethods module ObjectExtension def test_class(name) ExampleTest::latest_test_class = Class.new(Test::Unit::TestCase) ExampleTest::latest_test_case = 0 Object.const_set(name, ExampleTest::latest_test_class) end def example(version = RUBY_VERSION, &block) ExampleTest::latest_test_class.class_eval do define_method("test_%03d" % (ExampleTest::latest_test_case += 1), &block) end if RUBY_VERSION =~ Regexp.new(version.to_s) end end module TestExtension def assert_to_s(expected, actual) assert_equal(expected, actual.to_s) end def result_of(object) Result.new(object, self) end def output_of(object) Output.new(object, self) end class Result attr_accessor :object, :test_class def initialize(object, test_class) self.object = object self.test_class = test_class end def ==(string) test_class.assert_equal(string, object) end end class Output < Result def ==(string) test_class.assert_equal(string, object.to_s) end end end end class Test::Unit::TestCase include ExampleTest::TestExtension end class Object include ExampleTest::ObjectExtension end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
contextr-1.0.3 | test/lib/example_test.rb |
contextr-1.0.0 | test/lib/example_test.rb |
contextr-1.0.1 | test/lib/example_test.rb |
contextr-1.0.2 | test/lib/example_test.rb |