Class TestMetaFactory
In: lib/meta_factory.rb
Parent: ::Test::Unit::TestCase

Methods

Included Modules

Mocks::Assertions

Classes and Modules

Module TestMetaFactory::Mocks

Public Instance methods

[Source]

# File lib/meta_factory.rb, line 62
    def setup
      @proc = Proc.new { 42 }
      @proc2 = Proc.new { 43 }
      @mock_class = Mocks::Class.new
      self.mock_object = @mock_class
      assert_nothing_raised { @factory = MetaFactory.new(@mock_class, 42, :foo => :bar, &@proc) }
      assert_empty_mock
    end

[Source]

# File lib/meta_factory.rb, line 71
    def teardown
    end

[Source]

# File lib/meta_factory.rb, line 74
    def test_create
      10.times do
        assert_nothing_raised { @instance = @factory.create }
        assert_last_mock_call [:new, [42, {:foo=>:bar}], @proc]
      end
      assert_mock_size 10
    end

[Source]

# File lib/meta_factory.rb, line 82
    def test_create_with_args
      assert_nothing_raised { @instance = @factory.create([43], [:boo]) }
      assert_last_mock_call [:new, [43, 42, {:foo=>:bar}, :boo], @proc]
      assert_nothing_raised { @instance = @factory.create([45], &@proc2) }
      assert_last_mock_call [:new, [45, 42, {:foo=>:bar}], @proc2]
    end

[Source]

# File lib/meta_factory.rb, line 89
    def test_record
      assert_nothing_raised { @factory.record { |o| o.foo(:bar, :qux) } }
      assert_nothing_raised { @instance = @factory.create([43], [:boo]) }
      assert_last_mock_call [:new, [43, 42, {:foo=>:bar}, :boo], @proc]
      self.mock_object = @instance
      assert_mock_calls [[:foo, [:bar, :qux]]]
    end

[Validate]