Instant RSpec Test-Driven Development How-to

Learn RSpec and redefine your approach towards software development

Instant RSpec Test-Driven Development How-to

Starting
Charles Feduke

Learn RSpec and redefine your approach towards software development
$14.99
RRP $14.99
eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781782165224
Paperback68 pages

About This Book

  • 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

Who This Book Is 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.

Table of Contents

Chapter 1: Instant RSpec Test-Driven Development How-to
Installing RSpec (Simple)
Preparing the RSpec environment (Simple)
Refactoring specifications and classes (Simple)
Making specs more concise (Intermediate)
Handling exceptions (Intermediate)
Working with RSpec matchers (Simple)
Setting up Rails (Intermediate)
Writing ActiveRecord specifications (Intermediate)
Testing Rails routes (Intermediate)
Testing Rails controllers (Intermediate)
Stubbing (Intermediate)
Mocking (Intermediate)
Working with JSON (Intermediate)
Speccing file uploads (Advanced)
Integration testing with Capybara (Advanced)

What You Will Learn

  • 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

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.

Authors

Table of Contents

Chapter 1: Instant RSpec Test-Driven Development How-to
Installing RSpec (Simple)
Preparing the RSpec environment (Simple)
Refactoring specifications and classes (Simple)
Making specs more concise (Intermediate)
Handling exceptions (Intermediate)
Working with RSpec matchers (Simple)
Setting up Rails (Intermediate)
Writing ActiveRecord specifications (Intermediate)
Testing Rails routes (Intermediate)
Testing Rails controllers (Intermediate)
Stubbing (Intermediate)
Mocking (Intermediate)
Working with JSON (Intermediate)
Speccing file uploads (Advanced)
Integration testing with Capybara (Advanced)

Book Details

ISBN 139781782165224
Paperback68 pages
Read More