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.

Challenge: Guide

Challenge: Guide - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Challenge: Guide

- We’re ready for our fourth and final challenge: Writing specs for the Guide class. This is gonna be the most complicated of the four challenges. Mostly because we’re gonna be doing input and output on the command line. But don’t worry, I have some techniques that can help you out. In this challenge we’re gonna be seeing a couple more of the concepts that we’ve seen during this tutorial. We have “before(:example).” We’re gonna be using a true mock object using “double,” and “allow” will allow us to stub behaviors. We’re gonna be spying on a partial test double. You’ll see that we’ve used “skip” in place of ‘pending.’ And because we’re gonna be working with command line, we’ll be using our matcher for “output().to_stdout.” And there are also gonna be two helper methods that are gonna help you out: “setup_fake_input,” and “capture_output.” Altogether there are 14 pending examples, and I think they’ll take you approximately 45 minutes to an hour. Let’s begin by looking at those custom…

Contents