small medium large xlarge

21 May 2011, 12:36
Michael Blyth (4 posts)

I’ve only just gotten to the section Introducing IO under Making Your Tests Fast. The discussion jumps into using RSpec mocks without any explanation as far as I can see. I am a beginner with RSpec and am trying to make my way through The RSpec book, and the various ins and outs of mocks and related topics are still fuzzy to me. I think that the book needs a quick intro to the meaning and syntax of mocks, maybe in an appendix if you think it’s too basic for most of the readers.

An example of what is confusing to me is the line


I think I understand @should_receive@ as setting up a message expectation, but here is it replacing the actual Twitter::Search with a mock?

30 May 2011, 16:25
Andrés N. Robalino (4 posts)

RSpec mocks Twitter::Search’s new method and returns mock_client. Yes, it is basically disconnecting the real “new” method.

This is done after you test it works properly, once this happens… you mock it such that your test runs fast.

  You must be logged in to comment