Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loaderHowever, there is another factor that contributes to our test time: Stubba and Mocha. Stubba and Mocha have become tools that I would not want to live without.
Started
....................................................................................................................................
Finished in 0.555897 seconds.
132 tests, 219 assertions, 0 failures, 0 errors
Mocha is my new favorite mocking framework. Mocha's syntax is intuative and the mocks are auto-verified.
def test_execute(command='sql string', connection=mock)Stubba is similar to Mocha except it adds mock and stub capabilities to concrete classes.
connection.expects(:execute).with(command)
SqlExecutor.execute(command, connection)
end
def test_execute(command='sql string')Stubba can also be used for easy white box unit testing of specific methods. Stubba allows you to mock some methods of a concrete class while testing the actual implementations of the other methods.
DatabaseConnection.expects(:execute).with(command)
SqlExecutor.execute(command)
end
def test_parse(text='any text')Both Stubba and Mocha allow our tests to be concise and descriptive while increasing test performance.
Parser.expects(:preprocess).returns('condition.add')
Builder.expects(:build)
Parser.parse(text)
end
For more information on removing the database dependency check out this entry and for more info on Stubba and Mocha check out the RubyForge page.