You should check the desired result, not the implementation details. I would check the Logging module in isolation as follows:
describe Logging do TEST_IO = StringIO.new # some stub class for testing class Person include Logging log_to TEST_IO def name "Bob" end end after do TEST_IO.reopen end it "logs a method call to the given io" do person = Person.new TEST_IO.string.should eq("") person.name TEST_IO.string.should eq("name called\n") end # ... end
And I'm not sure that I will test a real class that uses this module in general, because it is very simple and contains any dangerous logic. Random errors, such as syntax errors, will be caught by the integration test.
source share