Å·±¦ÓéÀÖ

Jump to ratings and reviews
Rate this book

Effective Testing with RSpec 3: Build Ruby Apps with Confidence

Rate this book
Build and maintain quality software with RSpec, the popular BDD-flavored Ruby testing framework. This definitive guide from RSpec's lead developer shows you how to use RSpec to drive more maintainable designs, specify and document expected behavior, and prevent regressions during refactoring. Build a project using RSpec to design, describe, and test the behavior of your code-whether you're new to testing tools or an experienced developer.

RSpec has been downloaded more than 40 million times. Find out how to use this influential Ruby testing framework to iteratively develop a project with the confidence that comes from well-tested code. Effective Testing With RSpec 3 guides you through developing a Ruby project with RSpec, and then explores the individual components in more detail.

First, learn the basics of installing and using RSpec. Then, build a real-world JSON API, using RSpec throughout the process to drive a BDD-style outside-in workflow. Apply an effective test strategy to write fast, robust tests that support evolutionary design through refactoring. The rest of the book provides the definitive guide to RSpec's components. Use RSpec:: Core's metadata to slice and dice your spec suite in flexible ways. Dig into RSpec:: Expectation's matchers, which can be composed in flexible ways to precisely specify expected outcomes and get good failure messages that help you quickly diagnose the problem. Write fast, isolated tests with RSpec:: Mocks test doubles while pushing your code toward simpler interfaces.

The authors, with a combined 20 years of automated testing experience, share useful, actionable testing advice that will help you have a fun, productive testing experience.

What You Need:

To follow along with the book, you'll need Ruby 2.1+. The book will guide you through installing RSpec 3 and setting up a new project to use it.

356 pages, Paperback

Published October 3, 2017

51 people are currently reading
137 people want to read

About the author

Myron Marston

1Ìýbook1Ìýfollower

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
42 (50%)
4 stars
31 (36%)
3 stars
10 (11%)
2 stars
1 (1%)
1 star
0 (0%)
Displaying 1 - 12 of 12 reviews
Profile Image for Szymon.
48 reviews5 followers
July 7, 2019
So it looks like a had different expectations for this book.

If you are just getting started with the RSpec - this book is definitely for you.
I would also recommend this book to junior/mid Ruby/Rails developers who use RSpec on daily basis, but have never bothered too much about digging into how thing work under the hood.

To me, this book felt more like a human-friendly wrapper of the RSpec docs than a guide of 'How to test your app well with RSpec', which is something I was hoping for.

I would really appreciate more tips about how to make RSpec tests run faster, about what should be tested within unit specs and what should be left out for integration/acceptance tests, how not to overtest or simply a chapter about common programmers mistakes and misuses of the RSpec features.

I really enjoyed the chapter about Mocks/Stubs/Spies though. That gave me a bit more insight about how things actually work and why verified doubles are usually the way to go. Although I can imagine how this chapter could also be boring to someone very experienced with the RSpec - I guess it's not the case of the book being poorly written, it's just the case of what you expect from that book.
5 reviews1 follower
April 15, 2019
Before reading this book I've already known RSpec and used it a lot on daily basis in commercial projects, that's why I was even more eager to know what this book could possibly reveal to me. And I must say I was not dissapointed.

First of all, it's written by authors of RSpec, which gave me a feeling that I'm in right hands. With this attitude I started reading this book from the very beginning (even though it states, that current RSpec user can skip first 2 chapters) and I really appreciated doing so - it was good to get used to the author's flow, and gain the consciousness that I indeed know all the stuff (or at least 95%) described there from other sources. The fun part here was to realize what Matchers and Expectations really are - yes, we have diven deep into a Ruby world, so you probably won't be suprised, that they are just a Ruby objects :)

Next, we kick off a simple project written in Sinatra (but it's not required to do any coding) and focus on different parts of it - connecting with the database, sending requests etc., ending on integration tests.
What's more, authors don't only focus on RSpec, rather than convincing you, that you really should:
1. Write specs (not focusing on Rails at all!)
2. Write specs that really test the functionalities you just created
3. You keep away from false positives and other traps that are waiting just behind the corner.

We also get to configuring the RSpec, and we are told which things could be done via command line, and which should be places in actuall config file.

There are some treasures later on, such as using metadata (something like "tags") that for instance let you choose which specs to run - maybe those "tagged" with "fast" or "slow" tag? Or another one, that you partially knew, but only to certain extent. We use "it" a lot, "xit" in 1% of situations, but have you ever heard of "bit" inside your tests? It's really handfull option, that with addition of only one letter before "it" lets you run binding pry in this example! (but this functionality doesn't come out of the box!). Having this in mind, possibilities are almost endless - you can define your own keywords beyond group of "it", "xit" or "bit".

Another neat option is to create your own matchers and expectations, so instead of repetitively witing association chains, you could just define it once and later on refer to this definition, for instance:
expect(art_show).to have_no_tickets_sold
Pretty cool, huh?

But on the other hand, all of those functions can be really hard to understand by other devs at your project who haven't read this book - so bear in mind to let them know before doing this kind of magic ;)

There's a lot to be told about this book, but I would probably ran out of characters allowed by GoodReads to put all my insights about it. I highly recommend this book to all devs!

Last but not least, the book contains the receipt of how to get Nyan cat inside your specs!
Profile Image for Fotis Koutoulakis.
117 reviews13 followers
February 21, 2023
Outstanding book on software testing as a whole, and testing in a BDD style with Ruby and RSpec.

Recommended reading for every serious software engineer, if only to calibrate your expectations of what's possible using a well-designed software testing framework.
3 reviews
June 12, 2018

Excellent book. I'd call it the definitive guide for anyone who wish to learn not just RSpec, but OO software testing in general. It emphasizes more on testing concepts, rather than RSpec itself.

It includes exercises at the end of each chapter which help solidify concepts mentioned on previous pages. It doesn't only give you a thorough exposure to RSpec's features, but also includes a bunch of test antipatterns which act as signal for designing better your system. Last but not least, it includes dozens of links to other excellent resources (videos, blog posts, books), so it points you where to look next.

So, I definitely recommend this book for people new to testing/RSpec, but also for those who already use a testing framework but don't get the notions behind testing.

4 reviews
March 24, 2018
The book gives a good theoretical overview. It explains some important concepts of rspec like how matchers work, how to create custom matchers, how to configure RSpec.But I think it will be more effective if it had added more practical approach to it. It has one project in some early section but it does not continue to other parts of the book. It will be really good if the anyone who is reading it creates the project or projects along the reading.
Profile Image for Nitish Parkar.
45 reviews1 follower
November 30, 2020
This book can be thought of as a guided tour of the Rspec docs. It has an excellent explanation of the fundamental building blocks of Rspec. It will give you a new perspective on writing/arranging tests. Each chapter has an exercise section at the end to help you solidify the concepts learned.

This book is full of actionable advice. I would recommend it to anyone who uses Rspec, regardless of how many years they have been using it. Unless of course, you have gone through the Rspec docs.
19 reviews1 follower
November 7, 2017
The best book about testing with Rspec. It's not only up to date with recent RSpec (2017), but it also edited very well and it does not contain any bull**** examples like HelloWorld etc. It's straight to the point, with plenty of real world scenarios and practical advice. It also has a bunch of exercises at the end of each chapter, which might be really helpful if you are new to rspec.
Profile Image for Bogdan Agafonov.
1 review
October 24, 2017
The book introduces you to RSpec from basic usage to newer version updates and best practices, also showing some good usage and ideas behind TDD and when specs could guide your design decisions. I guess it could become your handbook for RSpec when finding yourself in difficult situations.
17 reviews
March 21, 2020
Great book on RSpec and on testing in general. It is a comprehensive guide for any RSpec user as well as it guides you how to write a better software via testing, pointing out to some issues that could be revealed during testing.
5 reviews
June 6, 2020
Probably the best book on TDD with RSpec, written by the author of RSpec himself.
Profile Image for Michael.
16 reviews3 followers
July 22, 2020
Not the best experience on Kindle but a good reference for teams getting started with RSpec
Profile Image for Pablo.
AuthorÌý1 book43 followers
April 3, 2020
Overall, this book is really good. I'm coming out of it feeling I know how to use all of Rspec and that there are no major mysteries. I feel that this is generally not true for computer books lately, unless it's a big book about a small part of programming, like this one. From this point of view, it was a pleasure to read. The typography and color of the book is really good and helps a lot with reading code snippets and test results (which are in color in the terminal).

I found a couple of things about the book a bit preachy. I find the assertions about Rspec's effect on quality, productivity, etc to be true for testing in general, not just for testing with Rspec. The book seems to be pushing for true unit testing as well, that is, mocking out the database. I would warn people against that, but that's a long discussion. The whole section of the philosophy of mocks, vs stubs, vs spies seemed unnecessary when they are just features of a system and Rspec already acknowledges this by calling all of them "doubles".

If you are coding and reading, reading and coding, and you are wondering about matchers, it takes a while for the book to start covering them but they seem to be covered reasonably well.
Displaying 1 - 12 of 12 reviews

Can't find what you're looking for?

Get help and learn more about the design.