I just start learn Ruby on Rails. When I research about RSpec test, I saw a recommend link about RSpec Mocks. However I don't know about the advantages of RSpec Mocks and how to use it. So can anyone summary about this.
Mocks help you to keep your tests clean. I'd recommend to start with integration tests (like cucumber for example). There you do not use mocks (unless perhaps something like WebMock, to capsulate your application from the outside world). You start with rspec unit tests as soon as you recognize the code gets complex, that you are going to write to make your integration test green. Now you capsulate your models from other models and your controllers from models with mocks. So the code you are going to write, to make rspec tests green, is not relying on other things. With mocks you just specify the bahaviour of all related stuff and it will behave as you defined. Of course you still have to test, that this other stuff will really fullfill these expectations. But when later implementation of some change request will break one model - really only the tests of that model will break. And everything that is related will still work, since the mocks behave, as defined. This way you find much easier and faster the real problems. Another advantage of course is, that you get along with much less database pollings.
I learnt Rspec and cucumber with the Rspec Book. It helped me to get the feeling about the advantages of the mocking approach.