everydayrails / everydayrails-rspec-2017

Sample source for the 2017 edition of Everyday Rails Testing with RSpec.
http://rspectutorial.com
312 stars 247 forks source link

[request/issue]: Expectations Using Procs #24

Open MutableLoss opened 6 years ago

MutableLoss commented 6 years ago

Specifically discussing the test environment is there anything to be aware of aside from the usual use of procs? In the feature spec chapter, they are referred to as “the expect{} Proc we checked out in chapter 5” (controller specs), but they are not discussed in that chapter, just used obscurely.

Huge thanks for this book!

ruralocity commented 6 years ago

There are a few other matchers that use blocks; I just either hardly ever use them, or have never needed them. I do use raise_error sometimes, and could probably work it into the book at some point. I agree that I hand-waved past this, though.

You might skim through the full list of built-in matchers provided by rspec-core at https://relishapp.com/rspec/rspec-expectations/v/3-6/docs/built-in-matchers/output-matcher

btw, thanks for posting these questions to GitHub—I like having the public forum for them, and if nothing else it makes sharing code samples easier :)

MutableLoss commented 6 years ago

Ah-ha, wow!

Huge thanks for that, and can see where having access to stdout, and stderr will certainly be helpful! I'm not sure how I missed that one, I probably ignored it thinking it was another page I looked at.

Prior to your book, I didn't even know that the DSL was using them as Procs, which helps give it context. The practice itself must be in another one of those dark corners of Rspec and Rails, I guess. Even so, I have to say this has been my favorite testing platform out of all of the languages I've done TDD/BDD in, there is something for everything with just a few packages. Thanks again!