Hi, everyone! I was hoping this blog would be about how to make a mock call to an API but unfortunately, I didn't have enough time to get to that. So today's short blog will be about what mocking is in RSpec. Let's begin!
"Mocking is a technique in test-driven development (TDD) that involves using fake dependent objects or methods in order to write a test." (1)
One handy thing to note about mocking, if you have the rspec gem as a dependency in your Gemfile then you already have the rspec-mocks gem available to use.
- Test Doubles
- Message Expectations
Over the next week I'll hopefully be able to give you all examples of successfully mocked API test for a project I'm working on, but in the meantime, please share with me anything that you think might be helpful!