RSpec Essentials

 
 
Packt Publishing Limited
  • 1. Auflage
  • |
  • erschienen am 21. April 2016
  • |
  • 222 Seiten
 
E-Book | ePUB mit Adobe DRM | Systemvoraussetzungen
978-1-78439-295-6 (ISBN)
 
Develop testable, modular, and maintainable Ruby software for the real world using RSpecAbout This BookExplore the concept of testability and how to implement tests that deliver the most valueMaximize the quality of your Ruby code through a wide variety of testsMaster the real-world tradeoffs of testing through detailed examples supported by in-depth discussionWho This Book Is ForThis book is aimed at the software engineer who wants to make their code more reliable and their development process easier. It is also aimed at test engineers who need to automate the testing of complex systems. Knowledge of Ruby is helpful, but even someone new to the language should find it easy to follow the code and tests.What You Will LearnIdentify a unit of software for the purposes of testingManage test states with hooks, fixtures, and mocksHandle external web services in tests using various techniquesConfigure RSpec flexibly and cleanly using support code and environment variablesInteract with rich web apps in tests using CapybaraBuild the right feature with behavior-driven developmentCustomize matchers and failure messagesVerify correct development and production environmentsIn DetailThis book will teach you how to use RSpec to write high-value tests for real-world code. We start with the key concepts of the unit and testability, followed by hands-on exploration of key features. From the beginning, we learn how to integrate tests into the overall development process to help create high-quality code, avoiding the dangers of testing for its own sake.We build up sample applications and their corresponding tests step by step, from simple beginnings to more sophisticated versions that include databases and external web services. We devote three chapters to web applications with rich JavaScript user interfaces, building one from the ground up using behavior-driven development (BDD) and test-driven development (TDD).The code examples are detailed enough to be realistic while simple enough to be easily understood. Testing concepts, development methodologies, and engineering tradeoffs are discussed in detail as they arise. This approach is designed to foster the reader's ability to make well-informed decisions on their own.Style and approachThis comprehensive tutorial is packed with real-world examples of testing with RSpec. The most important features of RSpec are introduced in the early chapters and are used in examples of growing complexity in the following chapters. Concepts and methodologies are discussed in detail.
  • Englisch
  • Birmingham
978-1-78439-295-6 (9781784392956)
1784392952 (1784392952)
weitere Ausgaben werden ermittelt
  • Cover
  • Copyright
  • Credits
  • About the Author
  • About the Reviewers
  • www.PacktPub.com
  • Table of Contents
  • Preface
  • Chapter 1: Exploring Testability from Unit Tests to Behavior-Driven Development
  • The promise of testing
  • Testability
  • Technical assumptions
  • Running our first spec
  • Understanding the unit test
  • Writing specs with RSpec
  • Test-driven development
  • Behavior-driven development
  • Summary
  • Chapter 2: Specifying Behavior with Examples and Matchers
  • Structure of a spec file
  • Using let and context
  • Matchers
  • Built-in matchers
  • Custom matchers
  • Enhanced context in matcher output
  • Creating a good custom error message
  • Improving application code
  • Testing for errors
  • Summary
  • Chapter 3: Taking Control of State with Doubles and Hooks
  • Why mock?
  • Mocks, stubs, and doubles
  • Using hooks
  • Controlling when hooks are executed
  • Advanced state control with hooks and mocks
  • Summary
  • Chapter 4: Setting Up and Cleaning Up
  • Configuring RSpec with spec_helper.rb
  • Initialization and configuration of resources
  • A case study of test simplicity with an external service
  • A case study of production faithfulness with a test resource instance
  • Summary
  • Chapter 5: Simulating External Web Services
  • The importance of external web services
  • Mock HTTP responses with custom helpers
  • Using real-world requests for mock responses
  • Using WebMock for mock HTTP requests
  • Using VCR for mock requests
  • Summary
  • Chapter 6: Driving a Web Browser with Capybara
  • Getting started with Capybara and Selenium
  • Integrating Capybara with RSpec
  • Why Capybara?
  • Black-box JavaScript tests with a real browser
  • Summary
  • Chapter 7: Building an App from the Outside In with Behavior-Driven Development
  • Exploring BDD
  • MMFs by example
  • Using TodoMVC
  • Specifying the MMF
  • Configuring RSpec to run a feature file
  • The BDD process begins
  • Building web apps with Rack
  • Serving static files using Rack middleware
  • Summary
  • Chapter 8: Tackling the Challenges of End-to-End Testing
  • Step 1 - building the view
  • Outside-in coding, Step 2 - defining the API
  • Step 3 - finishing the view
  • The pros and cons of BDD
  • Simple Rack authentication middleware
  • JSON Web Token
  • Summary
  • Chapter 9: Configurability
  • Configuration and testability
  • What is so important about configuration?
  • What does all this have to do with testing?
  • File-based configuration management
  • A better configuration manager
  • Summary
  • Chapter 10: Odds and Ends
  • Reducing duplication with shared example groups
  • Mocking time
  • Detecting false negatives and false positives
  • Testing mixins with dummy containers
  • Summary
  • Index

Dateiformat: EPUB
Kopierschutz: Adobe-DRM (Digital Rights Management)

Systemvoraussetzungen:

Computer (Windows; MacOS X; Linux): Installieren Sie bereits vor dem Download die kostenlose Software Adobe Digital Editions (siehe E-Book Hilfe).

Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions (siehe E-Book Hilfe).

E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m. (nicht Kindle)

Das Dateiformat EPUB ist sehr gut für Romane und Sachbücher geeignet - also für "fließenden" Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein "harter" Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.

Weitere Informationen finden Sie in unserer E-Book Hilfe.


Download (sofort verfügbar)

32,73 €
inkl. 19% MwSt.
Download / Einzel-Lizenz
ePUB mit Adobe DRM
siehe Systemvoraussetzungen
E-Book bestellen

Unsere Web-Seiten verwenden Cookies. Mit der Nutzung des WebShops erklären Sie sich damit einverstanden. Mehr Informationen finden Sie in unserem Datenschutzhinweis. Ok