Зарегистрироваться
Восстановить пароль
FAQ по входу

Chelimsky David. The RSpec Book. Behaviour-Driven Development with RSpec, Cucumber, and Friends

  • Файл формата pdf
  • размером 6,65 МБ
  • Добавлен пользователем
  • Описание отредактировано
Chelimsky David. The RSpec Book. Behaviour-Driven Development with RSpec, Cucumber, and Friends
Raleigh, North Carolina, Dallas, Texas - The Pragmatic Bookshelf - book version 1.0, December 2010 - 426 pages
ISBN10: 1-934356-37-9
ISBN13: 978-1-934356-37-1
Behaviour-Driven Development (BDD) gives you the best of Test Driven Development, Domain Driven Design, and Acceptance Test Driven Planning techniques, so you can create better software with self-documenting, executable tests that bring users and developers together with a common language.
Get the most out of BDD in Ruby with The RSpec Book, written by the lead developer of RSpec, David Chelimsky.
About this Book
You’ll get started right away with RSpec 2 and Cucumber by developing a simple game, using Cucumber to express high-level requirements in language your customer understands, and RSpec to express more granular requirements that focus on the behavior of individual objects in the system. You’ll learn how to use test doubles (mocks and stubs) to control the environment and focus the RSpec examples on one object at a time, and how to customize RSpec to speak in the language of your domain.
You’ll develop Rails 3 applications and use companion tools such as Webrat and Selenium to express requirements for web applications both in memory and in the browser. And you’ll learn to specify Rails views, controllers, and models, each in complete isolation from the other.
Whether you’re developing applications, frameworks, or the libraries that power them, The RSpec Book will help you write better code, better tests, and deliver better software to happier users.
Foreword
Caution! You’ve fallen for a trap. You’ve picked up this book thinking it was about RSpec. Fortunately, you decided to read the foreword. Good! That gives me the opportunity to tell you about the mistake you just made and possibly save you from an unexpected fate.
You see, this book isn’t about RSpec at all. Oh, RSpec is certainly mentioned. There are lots of examples of how to use it. There’s even a very detailed reference manual in Part III. But that’s all just part of an insidiously clever deception, because this book is not about RSpec.
Perhaps you thought you might read about Cucumber? After all, Part IV is named Cucumber. Oh, these authors are clever; God they are! They’ve littered this book with examples and details that tell you all about Cucumber in all its intricacies and all its copious fiddledy-bits. There’s even a section on using it with Rails and Webrat and all the other gory things that you’ll need to become a Cucumber expert. But this book is not about Cucumber.
No. This book is not about RSpec. And this book is not about Cucumber. This book is about...
I’m not sure I should tell you. I mean, once the secret gets out, it’s liable to cause mayhem. If it ever got out who the audience for this book really is, if the masses learned of the diabolical plan being executed in their midst, I’m not sure our civilization would survive.
You see...(come closer, and cover this part with your hand so nobody else can see it)...you see, this book is not for...(covered?)...it’s not for Ruby programmers!
There, I’ve said it! Now don’t panic, and don’t drop the book— whatever you do, don’t drop the book! Hold on tight, and keep it covered. Don’t let anyone else see.
Yes, you see, this book is not about RSpec. It’s not about Cucumber, It’s not for Ruby programmers. This book is for...(covered again?)...it’s for all programmers!
Keep a good tight grip. I know it’s hard. Don’t look around suspiciously. Don’t draw attention to yourself. Just try to stay calm, breathe normally, and keep reading.
Yes, all the code is in Ruby. Yes, all the examples use RSpec and Cucumber to one degree or another. Yes, if you read this book, you will learn RSpec, Cucumber, and things about Ruby and Rails and Webrat that you didn’t know before. No doubt about it. Remember, the best lies are near-truths.
Here’s the thing. While you read this book, you will think you are learning about all those cool tools. You will think Oh, cool, I’m learning RSpec and Cucumber. But you will be learning something else at the same time! Something unexpected. Something unadvertised. Something, perhaps, unwelcome.
As you read these pages, a hidden meme will creep into your mind—a meme of such potency and power that it is likely to change everything about the way you program. And not just how you program in Ruby! If you read this book, that meme will change the way you program in Java, C#, Python, or (oh, God, the thought) COBOL! This book will change the way you code—period!
Worse, you don’t have to be a Ruby programmer to be infected by this meme. As I said, these authors are clever. Their unholy plan is to infect all programmers with this meme. You see, they’ve cleverly constructed the Ruby code in this book so that it can be understood by (gasp) any programmer at all! I mean, this is worse than Fluoridation!
Any programmer who picks up this book will be infected by the meme. And the meme is subtle. And the meme is persistent. And the meme will have its way. And when it does, our industry will never be the same again. Are you willing to risk that?
What is this meme? What name shall we give it? The meme is legion! It’s not just Agile, though Agile is there. It’s not just TDD and BDD, though both are there. It’s not just Continuous Integration, Acceptance Test–Driven Development, Acceptance Test–Driven Planning, or even Extreme Programming, though all those things are present in the meme.
No, the meme is more than any one of those things. The meme is a synergistic witches brew of some of the most contagious and effective ideas of the past two decades. The meme is...
Dare I say it?
The meme is. Craftsmanship.
Robert C. Martin
(Uncle Bob)
Foreword
About the Authors
Ruby and Gem Versions
Downloading the Code Examples
What’s in This Book
I Getting Started with RSpec and Cucumber
-Test-Driven Development: Where It All Started
-Behaviour-Driven Development: The Next Step
-RSpec
-Cucumber
-The BDD Cycle
Hello
-Installation
-Hello RSpec
-Hello Cucumber
Describing Features
-Introducing Codebreaker
-Planning the First Release
-Planning the First Iteration
-What We’ve Learned
Automating Features with Cucumber
-Steps and Step Definitions
-Step Definition Methods
-Test Double
-What We’ve Learned
Describing Code with RSpec
-Getting Started with RSpec
-Red: Start with a Failing Code Example
-Green: Get the Example to Pass
-Refactor
-What We've Learned
Adding New Features
-Scenario Outlines in Cucumber
-Responding to Change
-What We've Learned
Specifying an Algorithm
-Begin with the Simplest Example
-Refactor to Remove Duplication
-Refactor to Express Intent
-What We've Learned
Refactoring with Confidence
-Sniffing Out Code Smells
-One Step at a Time
-Updating Specs After Refactoring
-Exploratory Testing
-What We've Learned
Feeding Back What We've Learned
-Use Cucumber for Collaboration
-Experimenting with a New Implementation
-What We've Learned
II Behaviour-Driven Development
The Case for BDD
-How Traditional Projects Fail
-Why Traditional Projects Fail
-Redefining the Problem
-The Cost of Going Agile
-What We've Learned
Writing Software That Matters
-A Description of BDD
-The Principles of BDD
-The Project Inception
-The Cycle of Delivery
-What’s in a Story?
-What We've Learned
III RSpec
Code Examples
-Describe It!
-Pending Examples
-Hooks: Before, After, and Around
-Helper Methods
-Shared Examples
-Nested Example Groups
-What We've Learned
RSpec::Expectations
-should, should_not, and matchers
-Built-in Matchers
-Predicate Matchers
-Be True in the Eyes of Ruby
-Have Whatever You Like
-Operator Expressions
-Generated Descriptions
-Subjectivity
-What We've Learned
RSpec::Mocks
-Test Doubles
-Method Stubs
-Message Expectations
-Test-Specific Extensions
-More on Method Stubs
-More on Message Expectations
-When to Use Test Doubles and Test-Specific Extensions
-Risks and Trade-Offs
-Choosing Other Test Double Frameworks
-What We've Learned
Tools and Integration
-The rspec Command
-TextMate
-Autotest
-Rake
-RCov
-What We've Learned
Extending RSpec
-Metadata
-Configuration
-Filtering
-Extension Modules
-Global Hooks
-Mock Framework
-Custom Matchers
-Macros
-Custom Formatters
-What We've Learned
IV Cucumber
Intro to Cucumber
-From 20,000 Feet
-Features
-Customer Acceptance Tests
-Gherkin
-Scenarios
-Steps
-The cucumber Command
-Given/When/Then
-Declarative and Imperative Scenario Styles
-Organizing Features
-Tags
-What We've Learned
Cucumber Detail
-Step Definitions
-World
-Calling Steps Within Step Definitions
-Hooks
-Background
-Multiline Text
-Tables in Steps
-Scenario Outlines
-Configuration
-What We've Learned
V Behaviour-Driven Rails
BDD in Rails
-Outside-In Rails Development
-Setting Up a Rails 3 Project
-Setting Up a Rails 2 Project
-What We've Learned
Cucumber with Rails
-Step Definition Styles
-Direct Model Access
-What We've Learned
Simulating the Browser with Webrat
-Writing Simulated Browser Step Definitions
-Navigating to Pages
-Manipulating Forms
-Specifying Outcomes with View Matchers
-Building on the Basics
-What We've Learned
Automating the Browser with Webrat and Selenium
-Getting Started
-Writing Step Definitions for Selenium
-Debugging Selenium Issues
-What We've Learned
Rails Views
-Writing View Specs
-Mocking Models
-Specifying Helpers
-When Should I Write View Specs?
-What We've Learned
Rails Controllers
-Controller Specs
-Context-Specific Examples
-Specifying ApplicationController
-What We've Learned
Rails Models
-Writing Model Specs
-Specifying Business Rules
-Exercise
-Useful Tidbits
-What We've Learned
RubySpec
The Project
Syntax
Guards
Extensibility
MSpec
Tags
Community
RSpec’s Built-in Expectations
  • Чтобы скачать этот файл зарегистрируйтесь и/или войдите на сайт используя форму сверху.
  • Регистрация