Jump to ratings and reviews
Rate this book

Instant RSpec Test-Driven Development How-to

Rate this book
RSpec is a behaviour driven development framework for Ruby programmers. It comes integrated with its own mocking framework based on Jmock. This book introduces you to RSpec helping you to write idiomatic specifications for Ruby code in a test first approach.

Instant RSpec Test-Driven Development How-to is filled with examples of actual code accompanied by explanations and covers general Ruby, Rails, and RSpec use cases plus a few of the more advanced topics. RSpec Test Driven Development is written on the premise that you will need no experience with RSpec and limited experience with Ruby, Rails, and TDD fundamentals. You’ll begin by writing a very simple Ruby library in true TDD fashion and and use the red, green, refactor tools to migrate this library into a Rails application.

Instant RSpec Test-Driven Development How-to will teach you the actual steps performed in writing an idiomatic specification. You will be able to write a test for the code you wish you had, and learn to write only the minimum code necessary to pass a test, and write more specifications to drive out the production functionality your application will need. Through the course of the book, you will convert a Ruby program into a new Rails application, test Rails specifics such as file uploads, cookies, and model validation and even learn how to use Capybara. RSpec Test Driven Development will help you build confidence in the code they you write and spend less time dealing with bugs and maintenance headaches.

54 pages, ebook

First published June 1, 2013

2 people are currently reading
17 people want to read

About the author

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
0 (0%)
4 stars
4 (30%)
3 stars
6 (46%)
2 stars
3 (23%)
1 star
0 (0%)
Displaying 1 - 5 of 5 reviews
Profile Image for Antonio.
98 reviews
January 27, 2014

Learn RSpec and redefine your approach towards software development

Overview

Learn something new in an Instant! A short, fast, focused guide delivering immediate results Learn how to use RSpec with Rails Easy to read and grok examples Write idiomatic specifications

In Detail

RSpec is a behaviour driven development framework for Ruby programmers. It comes integrated with its own mocking framework based on Jmock. This book introduces you to RSpec helping you to write idiomatic specifications for Ruby code in a test first approach.

Instant RSpec Test-Driven Development How-to is filled with examples of actual code accompanied by explanations and covers general Ruby, Rails, and RSpec use cases plus a few of the more advanced topics. RSpec Test Driven Development is written on the premise that you will need no experience with RSpec and limited experience with Ruby, Rails, and TDD fundamentals. You’ll begin by writing a very simple Ruby library in true TDD fashion and and use the red, green, refactor tools to migrate this library into a Rails application.

Instant RSpec Test-Driven Development How-to will teach you the actual steps performed in writing an idiomatic specification. You will be able to write a test for the code you wish you had, and learn to write only the minimum code necessary to pass a test, and write more specifications to drive out the production functionality your application will need. Through the course of the book, you will convert a Ruby program into a new Rails application, test Rails specifics such as file uploads, cookies, and model validation and even learn how to use Capybara. RSpec Test Driven Development will help you build confidence in the code they you write and spend less time dealing with bugs and maintenance headaches.

What you will learn from this book

RSpec fundamentals How to use RSpec and Rails together Modify your behavior to create tests first and run your specs with every code change How to work with the rspec command line tool Using mocks and stubs to decouple tests from the database How to refactor code to improve readability

Approach

Filled with practical, step-by-step instructions and clear explanations for the most important and useful tasks. A concise guide that delivers immediate results with practical recipes on learning practical hints.

Who this book is written for

This book is aimed at Ruby developers with beginner level expertise who want to use RSpec and test driven development methodology to improve the code they write. Experienced programmers new to Ruby will also benefit from this book which also covers creating testable, idiomatic Ruby code.

**

Profile Image for Katherine.
149 reviews
July 21, 2013
The book title by itself should give you a hint that it's more of a quick read than a definitive guide on Test-Driven Development. The books I have read on TDD and BDD (Behaviour-driven Development) are about four to five times lengthier. Verbosity is not needed when you want to learn something quickly probably for a new job or a new project. You still might find yourself googling a lot after reading those lengthy books anyway.

I could skim through the book in less than an hour but because it's for review, I read it word by word for a much longer time and tried to see if there are any gotchas.

The Good


It started off by explaining about conventions and how to use the "rspec" command with the options like showing the progress.
The author did not fail to explain the "Red-green-refactor" process throughout the book.
The author followed the community-accepted standards of writing better test code. To learn more about that, you can read the open source book called Better Specs
There are practical examples for all chapters.
While it is a quick read, the author did well in explaining the difference between "stubbing" and "mocking". Beginners will initially find this confusing but as you code more, it won't be confusing anymore.


The Bad


Like many books, there are typographical errors. But I like this one because it is funny: "it is important to execute the verify it fails step for new code to ensure you're not a monkey..." I think that error should have been an intentional pun. It's more fun that way so people will remember to follow TDD. I made several mistakes by skipping that process. I should remember that and not think like a "monkey."
There are examples on the first few chapters which I could have written differently. I could have used let instead of defining the variable within the it block for example.



Final Notes

Test it, don't guess it.

Enjoy reading this book published recently.




Instant RSpec Test-Driven Development How-to
3 reviews
July 13, 2013
Instant RSpec Test Driven Development How-to, by Charles Feduke, is another book in the Instant series published by Pakt Publishing designed to get the reader up and running quickly (Short, Fast, Focused). This book covers test driven development (TDD) using rspec with ruby and is designed for developers of all experience levels.

As a solutions architect who supports rails applications which are written with rspec tests, this book bridges a gap to give me more familiarity with the tests which are relied upon to validate application code.

While reading through this book I was able to quickly and easily get my environment setup with the appropriate gems and packages installed, as well as begin development on a basic application using test driven development. Charles walks the reader through creating a sample application and later on moving that into a rails application with ActiveRecord.

There were many examples throughout the book and it lends itself to following along with a shell window open beside the e-reader. I found myself wondering what some of the examples were doing at times but Charles always came through and explained them within a few pages to satisfy my curiousity. The presentation method in this book is to get you up and running and then explain things a bit later on. I'm sure those more familiar with ruby development would catch on a bit quicker.

While Charles does a great job in this book explaining code refactoring, creating concise code blocks, and giving great examples, he calls out a difference in mocking and stubbing but doesn't really explain what this critical difference is in a way that I understood it. He also covers JSON validation and file uploads which seem required for every API lately.

The book ends with coverage of capybara for client side testing. This is a great end to the book as after you develop your application function it's time to validate that the user experience is as expected.

Overall, this was a good read. I thought it was a bit above my level, as far as ruby experience goes, but a useful tool that I will reference and use in the future as I continue to work and learn on ruby/rails projects. Thanks, Charles, I look forward to seeing more in the future.
Profile Image for Rodrigo Martín.
7 reviews
July 13, 2013
Having worked with rspec for a year or so, I found this recipe book as a good way to refresh some of the concepts and techniques of this excellent framework. The recipes are clear and concise. I would love to have more background on theory or concepts as well. All in all it's a good choice for people working with rspec who wants to learn some tricks and good practices, and for people new to this framework as well, as a complement of other forums and the API docs itself. The UI automation chapter with Capybara is a good plus!

Instant RSpec Test-Driven Development How-to
Profile Image for Nephi.
54 reviews
March 6, 2014
Too short for any depth and I believe it is already dated.
Displaying 1 - 5 of 5 reviews

Can't find what you're looking for?

Get help and learn more about the design.