DEV Community

Aliya Lewis
Aliya Lewis

Posted on

Are you "mocking" me?

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!

What is mocking?

"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.

Things I've Heard in Relation to Mocking

  • Test Doubles
  • Stubs
  • Message Expectations

Next Steps

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!

Resources

1) Mocking with RSpec: Doubles and Expectations

2) Project: RSpec Mocks 3-9

Top comments (0)