Module Lafcadio::DomainMock
In: lafcadio/test.rb

A convenience module for test-cases of Lafcadio-dependent applications. Include this module in a test-case, and you automatically get the class-level method setup_mock_dobjs. This calls DomainObject.default_mock, and assigns the result to an instance variable named after the domain class. Note that if your test case also defines a setup, you should make sure to call super in that setup method to make setup_mock_dobjs work.

  class User < Lafcadio::DomainObject
    strings :fname, :lname, :email

  class TestSendMessage < Test::Unit::TestCase
    include Lafcadio::DomainMock
    setup_mock_dobjs User
    def test_send_to_self 'sender' => @user, 'recipient' => @user )
      assert_equal( 1, Message.all.size )

setup_mock_dobjs can handle plural domain classes:

  setup_mock_dobjs User, Message

It can also handle assignments to different instance variables:

  setup_mock_dobjs User, '@sender'


Public Class methods

Public Instance methods