Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mattwynne/bdd-as-if-you-meant-it
base: d8dc7d47de
...
head fork: mattwynne/bdd-as-if-you-meant-it
compare: cca004a1d3
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 13 additions and 3 deletions.
  1. +13 −3 features/step_definitions/steps.rb
View
16 features/step_definitions/steps.rb
@@ -29,7 +29,14 @@ def last_amount_dispensed
end
class Account
- def balance
+ attr_reader :balance
+
+ def initialize(balance)
+ @balance = balance
+ end
+
+ def debit(amount)
+ @balance -= amount
end
end
@@ -39,15 +46,18 @@ def initialize(cash_dispenser)
end
def authenticate_as(account)
+ @account = account
end
def withdraw(amount)
+ @account.debit(amount)
@cash_dispenser.dispense(amount)
end
end
module DomainDriver
def create_account(balance)
+ @my_account = Account.new(balance)
end
def withdraw(amount)
@@ -60,13 +70,13 @@ def cash_dispenser
end
def my_account
- Account.new
+ @my_account || raise("Please call #create_account first!")
end
private
def teller
- Teller.new(cash_dispenser)
+ @teller ||= Teller.new(cash_dispenser)
end
end

No commit comments for this range

Something went wrong with that request. Please try again.