Posted about 1 month ago. Visible to the public.

How to reset a Mock

With Rspec you can mock objects or functions, for example like this:

Copy
expect(my_object).to receive(:my_function).and_return('hello world')

It's also easy to remove mocks for an object:

Copy
RSpec::Mocks.space.proxy_for(my_object).reset

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Avatar
Judith Roth
Last edit:
about 1 month ago
by Judith Roth
Keywords:
unmock
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more