The RSpec Book
Subtitle: Behaviour-Driven Development with RSpec, Cucumber, and Friends
Publisher: The Pragmatic Programmers
Published: 2010-12-02
Language: eng
Number of pages: 420
ISBN-13: 9781934356371
Description: Provides information on developing Rails 3 applications using RSpec and Cucumber.
Table of contents: label: Part 1
title: Getting Started with RSpec and Cucumber
pagenum: 23; label: 1
title: Introduction
pagenum: 24; label: 1.1
title: Test-Driven Development: Where It All Started
pagenum: 24; label: 1.2
title: Behaviour-Driven Development: The Next Step
pagenum: 26; label: 1.3
title: RSpec
pagenum: 27; label: 1.4
title: Cucumber
pagenum: 28; label: 1.5
title: TheBDDCycle
pagenum: 30; label: 2
title: Hello
pagenum: 32; label: 2.1
title: Installation
pagenum: 32; label: 2.2	HelloRSpec .......................	33 2.3	HelloCucumber.....................	35; title: 3	Describing Features	39 3.1	IntroducingCodebreaker................	40 3.2	PlanningtheFirstRelease ...............	40 3.3	PlanningtheFirstIteration ..............	46 3.4	WhatWe’veLearned...................	54; title: CONTENTS	8; title: 4	Automating Features with Cucumber	55; title: 4.1	Steps and Step Definitions . 4.2	Step Definition Methods	.. 4.3	TestDouble ....... .. 4.4	What We’ve Learned . . . ..; title: 5	Describing Code with RSpec; title: ..............	57 ..............	58 ..............	62 ..............	64; title: 65; title: 5.1	Getting Started with RSpec 5.2	Red:StartwithaFailingCodeExample.......	68 5.3	Green:GettheExampletoPass. . . . . . . . . . . .	70 5.4	Refactor..........................	74 5.5	WhatWe’veLearned...................	78; title: 6	Adding New Features	79 6.1	ScenarioOutlinesinCucumber . . . . . . . . . . . .	79 6.2	RespondingtoChange .................	82 6.3	WhatWe’veLearned...................	85; title: 7	Specifying an Algorithm	86 7.1	BeginwiththeSimplestExample . . . . . . . . . . .	86 7.2	RefactortoRemoveDuplication . . . . . . . . . . . .	90 7.3	RefactortoExpressIntent ...............	91 7.4	WhatWe’veLearned...................	96; title: 8	Refactoring with Confidence	98 8.1	SniffingOutCodeSmells................	98 8.2	OneStepataTime ...................	100 8.3	UpdatingSpecsAfterRefactoring . . . . . . . . . . .	109 8.4	Exploratory Testing . . . . . . .............	113 8.5	WhatWe’veLearned. . . . . . .............	114; title: 9	Feeding Back What We’ve Learned; title: 116; title: 9.1	UseCucumberforCollaboration . . . . . . . . . . .	116 9.2	Experimenting with a New Implementation . . . . .	120 9.3	WhatWe’veLearned...................	124; title: ..............	65; title: CLICK HERE to purchase this book now.; title: CONTENTS	9; title: II 10; title: 11; title: III 12; title: 13; title: Behaviour-Driven Development	126; title: The Case for BDD	127 10.1 HowTraditionalProjectsFail.............	127 10.2 WhyTraditionalProjectsFail.............	128 10.3	RedefiningtheProblem.................	132 10.4	TheCostofGoingAgile.................	135 10.5	WhatWe’veLearned...................	138; title: Writing Software That Matters	140 11.1	ADescriptionofBDD..................	140 11.2	ThePrinciplesofBDD .................	140 11.3 TheProjectInception ..................	141 11.4 TheCycleofDelivery .................. 143 11.5	What’sinaStory?....................	147 11.6	WhatWe’veLearned...................	150; title: RSpec	151; title: Code Examples	152 12.1	DescribeIt!........................	153 12.2	PendingExamples....................	157 12.3 Hooks:Before,After,andAround . . . . . . . . . . .	160 12.4 HelperMethods ..................... 164 12.5 SharedExamples .................... 166 12.6 NestedExampleGroups ................ 168 12.7	WhatWe’veLearned...................	171; title: RSpec::Expectations	172 13.1 should,should_not,andmatchers..........	173 13.2 Built-inMatchers .................... 174 13.3 PredicateMatchers ................... 182 13.4	BeTrueintheEyesofRuby..............	183 13.5 HaveWhateverYouLike ................ 184 13.6	OperatorExpressions..................	188 13.7	GeneratedDescriptions.................	189 13.8	Subjectivity........................	190 13.9	WhatWe’veLearned...................	192; title: CLICK HERE to purchase this book now.; title: CONTENTS	10; title: 14 RSpec::Mocks	193 14.1	TestDoubles.......................	194 14.2 MethodStubs ...................... 195 14.3	MessageExpectations .................	197 14.4 Test-SpecificExtensions ................ 199 14.5 MoreonMethodStubs .................	203 14.6 MoreonMessageExpectations . . . . . . . . . . . .	205 14.7	When to Use Test Doubles and Test-Specific Exten-; title: sions ........................... 215 14.8	RisksandTrade-Offs..................	220 14.9	Choosing Other Test Double Frameworks . . . . . .	222 14.10 WhatWe’veLearned...................	224; title: 15	Tools and Integration	226 15.1 TherspecCommand .................. 226 15.2 TextMate ......................... 231 15.3	Autotest..........................	232 15.4	Rake............................	232 15.5 RCov ........................... 234 15.6	WhatWe’veLearned...................	235; title: 16	Extending RSpec	236 16.1 Metadata ......................... 236 16.2 Configuration ...................... 237 16.3	Filtering..........................	237 16.4 ExtensionModules ................... 240 16.5	GlobalHooks.......................	241 16.6 MockFramework .................... 241 16.7 CustomMatchers ....................	242 16.8 Macros .......................... 246 16.9	CustomFormatters...................	249 16.10 WhatWe’veLearned...................	252; title: IV	Cucumber	253; title: 17	Intro to Cucumber	254 17.1 From20,000Feet ....................	255 17.2 Features ......................... 255 17.3 CustomerAcceptanceTests .............. 259 17.4	Gherkin..........................	259 17.5	Scenarios.........................	261; title: CLICK HERE to purchase this book now.; title: CONTENTS	11; title: 17.6 Steps ........................... 262 17.7	ThecucumberCommand ...............	263 17.8 Given/When/Then ................... 264 17.9 Declarative and Imperative Scenario Styles . . . . .	265; title: 17.10 Organizing Features 17.11 Tags.......... 17.12 What We’ve Learned .; title: 18	Cucumber Detail; title: ..................	266 ..................	267 ..................	269; title: 271; title: 18.1 StepDefinitions ..................... 271 18.2 World ........................... 273 18.3	Calling Steps Within Step Definitions	. . . . . . . .	274 18.4	Hooks...........................	275 18.5 Background ....................... 277 18.6 MultilineText ...................... 278 18.7	TablesinSteps .....................	279 18.8	ScenarioOutlines....................	280 18.9 Configuration ...................... 282 18.10 WhatWe’veLearned...................	282; title: V	Behaviour-Driven Rails	284; title: 19	BDD in Rails	285 19.1 Outside-InRailsDevelopment.............	286 19.2 SettingUpaRails3Project .............. 288 19.3 SettingUpaRails2Project .............. 291 19.4	WhatWe’veLearned...................	291; title: 20	Cucumber with Rails	292 20.1	StepDefinitionStyles..................	292 20.2	DirectModelAccess...................	294 20.3	WhatWe’veLearned...................	299; title: 21	Simulating the Browser with Webrat	300 21.1	Writing Simulated Browser Step Definitions . . . . .	301 21.2 NavigatingtoPages ...................	306 21.3	ManipulatingForms ..................	310 21.4	Specifying Outcomes with View Matchers . . . . . .	315 21.5 BuildingontheBasics ................. 318 21.6	WhatWe’veLearned...................	321; title: CLICK HERE to purchase this book now.; title: CONTENTS	12; title: 22	Automating the Browser with Webrat and Selenium	322 22.1	GettingStarted .....................	323 22.2 Writing Step Definitions for Selenium . . . . . . . .	326 22.3 DebuggingSeleniumIssues .............. 330 22.4	WhatWe’veLearned...................	332; title: 23	Rails Views	333 23.1 WritingViewSpecs ................... 333 23.2 MockingModels .....................	336 23.3	SpecifyingHelpers....................	343 23.4 WhenShouldIWriteViewSpecs?. . . . . . . . . . .	345 23.5	WhatWe’veLearned...................	345; title: 24	Rails Controllers	347 24.1	ControllerSpecs.....................	347 24.2	Context-SpecificExamples...............	354 24.3 Specifying ApplicationController . . . . . . . . . . .	363 24.4	WhatWe’veLearned...................	365; title: 25	Rails Models	367 25.1	WritingModelSpecs ..................	367 25.2	SpecifyingBusinessRules...............	375 25.3	Exercise..........................	384 25.4 UsefulTidbits ...................... 385 25.5	WhatWe’veLearned...................	388; title: A	RubySpec	390 A.1	TheProject........................	391 A.2 Syntax .......................... 391 A.3 Guards .......................... 393 A.4 Extensibility ....................... 394 A.5	MSpec...........................	396 A.6	Tags............................	396 A.7	Community........................	397; title: B	RSpec’s Built-in Expectations	399 C	Bibliography	403