stub snippets

Mocha stubbing and mocking

Tagged mocha, stub, mock, test  Languages ruby

Mocking with expectations:

@domain = Domain.new
Domain.expects(:new).returns(@domain)
@domain.errors.add(:name, 'WTF')

Stubbing:

Domain.stubs(:new).returns(@domain)