Chapter 8
Support Code

In the previous chapter, we started working through an example of how to use Cucumber to build a real application, outside-in. The system we’re building is an Automated Teller Machine (ATM) for a bank, and we used Cucumber to help us design a simple domain model that satisfied this scenario:

 Feature​: Cash Withdrawal
 Scenario​: Successful withdrawal from an account in credit
  Given I have deposited $100 in my account
  When I withdraw $20
  Then $20 should be dispensed

The code we’ve written makes the scenario pass, but the system isn’t really of any use yet: there’s no external interface for a user to interact with, just a handful of Ruby classes. Now we’re going to fix that, by wrapping the domain model with a user interface where the user can request the amount of cash they want to withdraw.

In this chapter, we’re going to focus mostly on the code in the features/support folder. This is the lowest level of your test code, where it connects or couples to your actual application. If this coupling is well-engineered, your tests will be a pleasure to modify as your project grows. If the coupling is too tight, your tests will be brittle and break any time anything moves. That’s why we created a separation layer between the step definitions and the system using a module of helper methods mixed into the World. This separation layer provides just the decoupling we’ll need as we start to introduce a user interface.

Before we get started with the user interface, we have one item left on our to-do list we need to check off first.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.187.62