tags:

views:

24

answers:

1

I dont get why I should use Mocks in Rspec.

If I write Specs, shouldn't I write the actual code afterwards so that the tests would pass?

So why use Mocks and replace those actual classes?

+1  A: 

I'm not too familiar with RSpec, but generally you use mocks for everything that you don't want to test.

Mocks are the things that you use to replace anything but the class under test, so that you have this class in complete isolation. Only then it is a real unit test, otherwise you would test the class under test and all depending/called classes as well, which would then be an integration test (which is useful in certain scenarios, but it's for sure nothing that you would want to have in TDD/BDD...).

Thomas

Thomas Weller