Sha256: 3ef7150a95313acb138665cd87c8064b96a2c9bb6d35621e449494bdf5a0e081
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# Copyright (c) 2010 Paolo Capriotti <p.capriotti@gmail.com> # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 3 of the # License, or (at your option) any later version. require 'test/unit' require 'rui/factory' class TestFactory < Test::Unit::TestCase def test_simple_factory factory = Factory.new { "hello" } assert_equal "hello", factory.new end def test_factory_with_arguments factory = Factory.new {|x, y| x + y } assert_equal 42, factory.new(40, 2) end def test_component factory = Factory.new(Array) do |n, value| Array.new(n) { value } end assert_equal Array, factory.component assert_equal Array, factory.new(10, "hello").class end def test_rebind factory = Factory.new(Array) do |n, value| new(n) { value } end factory = factory.__bind__(factory.component) assert_equal Array, factory.component assert_equal [:hello, :hello], factory.new(2, :hello) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rui-0.1.2 | test/test_factory.rb |
rui-0.1.0 | test/test_factory.rb |