You are previewing Instant RSpec Test-Driven Development How-to.
O'Reilly logo
Instant RSpec Test-Driven Development How-to

Book Description

Learn RSpec and redefine your approach toward software development

  • 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.

Table of Contents

  1. Instant RSpec Test-Driven Development How-to
    1. Instant RSpec Test-Driven Development How-to
    2. Credits
    3. About the Author
    4. About the Reviewers
    5. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt Publishing account holders
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
      7. Downloading the example code
      8. Errata
      9. Piracy
      10. Questions
    7. 1. Instant RSpec Test-Driven Development How-to
      1. Installing RSpec (Simple)
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more...
      2. Preparing the RSpec environment (Simple)
        1. How to do it...
        2. There's more…
      3. Refactoring specifications and classes (Simple)
        1. How to do it...
        2. How it works...
      4. Making specs more concise (Intermediate)
        1. How to do it...
        2. How it works...
        3. There's more...
      5. Handling exceptions (Intermediate)
        1. How to do it...
        2. There's more...
      6. Working with RSpec matchers (Simple)
        1. How to do it...
      7. Setting up Rails (Intermediate)
        1. How to do it...
      8. Writing ActiveRecord specifications (Intermediate)
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Gemfile environments
          2. spec_helper.rb
          3. rake spec
      9. Testing Rails routes (Intermediate)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      10. Testing Rails controllers (Intermediate)
        1. How to do it...
      11. Stubbing (Intermediate)
        1. How to do it...
        2. How it works...
      12. Mocking (Intermediate)
        1. How to do it...
      13. Working with JSON (Intermediate)
        1. How to do it...
      14. Speccing file uploads (Advanced)
        1. Getting ready
        2. How to do it...
        3. There's more...
      15. Integration testing with Capybara (Advanced)
        1. Getting ready
        2. How to do it...
        3. There's more...
          1. Capybara
          2. Specification tagging