O'Reilly logo

The Cucumber Book, 2nd Edition by Steve Tooke, Aslak Hellesoy, Matt Wynne

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to Synchronize

In our current implementation, the debit and credit transactions are processed synchronously by our simplistic Account class:

 class​ Account
 def​ credit(amount)
  @balance = amount
 end
 
 def​ balance
  @balance
 end
 
 def​ debit(amount)
  @balance -= amount
 end
 end

This implementation, where the balance is updated during the method call to credit or debit, means that we can be certain the balance will have been updated by the time Cucumber checks the account balance in the final Then step of our scenario.

 Feature​: Cash Withdrawal
 Scenario​: Successful withdrawal from an account in credit
  Given my account has ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required