Why use mocks in rspec?

I do not understand why I should use Mocks in Rspec.

If I write Specs, should I not write the actual code after this so that the tests pass?

So, why use Mocks and replace these actual classes?

+3
source share
1 answer

I do not know much about RSpec, but usually you use mocks for everything that you do not want to test.

Mocks is what you use to replace anything other than the class you are testing so that you have this class in complete isolation. Only then is it a real unit test, otherwise you would test the tested class and all dependent / called classes, which would then be an integration test (which is useful in certain scenarios, but it probably wouldn’t do anything you want to have in TDD / BDD ...) .

Thomas

+3
source

Source: https://habr.com/ru/post/1759105/


All Articles