Alex Rivera | Logout

What is the difference between mock and mock_model in RSpec

Asked 2009-08-12T01:26:11.680
34

I've recently came across different tutorials, where people use both mock and mock_model functions.

In RSpec tutorial for controllers they use the mock_model function, but right in the documentation of RSpec, there is only mock function, but no mock_model

I tried to run some tests myself, and I didn't find any real difference, since everything was ok when I used either of those two functions, so is there any difference at all?

Edit
Report

1 Answer

9

From: Useful helpers for RSpec mocks

Firstly, mock_model automatically defines unique ids for models, which were created using it. Secondly, it defines methods to_param (returns string representation of the id) and new_record? (returns false).

answered 2009-08-12T02:18:30.677

Your Answer