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.
Message expectations - Ruby Tutorial
From the course: Ruby: Testing with RSpec
Message expectations
- In this movie, we'll learn about setting message expectations. Remember, Ruby sends messages to objects in order to call methods and RSpec can then set expectations about those messages. It's not at all related to any text messages or error messages that the user might see. That's not the kind of messages that we're talking about. We're talking about the messages that objects send in order to trigger methods. In the last movie, we saw how to allow messages. So, for example, we allowed our double to receive (:hey!) and return ("Ho!"). (:hey!) is the message. In this next line, we are doing an expectation on that. We're saying that we would expect that when we call (:hey!) that then it would respond with ("Ho!") but that's not a message expectation. To write a message expectation, we would need to switch the word allow to be expect. So, watch that second line as I switch to the next slide and see that it's just changed so that it says instead of allowing the dbl to receive (":hey")…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.