From the course: Ruby: Testing with RSpec

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Guide

Solution: Guide - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Solution: Guide

- Hopefully you were able to write all the examples in the Guide Challenge. If not, I'm going to show you my solution now. So inside my guide_spec file I'm going to skip down to the first example that we needed to write, which is #initialize. It should call Restaurant#load with its path argument. The argument that gets passed in. So we know that we're going to have to call Guide.new and pass in that test_file path as an argument. Here's our message expectation. We're setting before we call Guide.new, we're telling Restaurant that it should expect to receive load_file with that test_file. So if it does then it'll pass. If it doesn't then it won't. Notice that we're doing that before we call the code. We're not spying on it, we're setting a message expectation ahead of time. Next we have #launch!, it should just simply output an introductory message when it gets launched. So what do we do, we just launch it and then quit right away. So here it is, we're going to expect when we call…

Contents