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: aba175ae95
...
head fork: mattwynne/bdd-as-if-you-meant-it
compare: d8dc7d47de
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
2  .gitignore
@@ -18,4 +18,4 @@ _yardoc
doc/
# VIM
-**/*.swp
+*.swp
View
BIN  features/step_definitions/.steps.rb.swp
Binary file not shown
View
34 features/step_definitions/steps.rb
@@ -11,7 +11,7 @@
end
Then /^(#{AMOUNT}) should be dispensed$/ do |amount|
- cash_dispenser.contents.should == amount
+ cash_dispenser.last_amount_dispensed.should == amount
end
Then /^the balance of my account should be (#{AMOUNT})$/ do |amount|
@@ -19,14 +19,30 @@
end
class CashDispenser
- def contents
- 50
+ def dispense(amount)
+ @last_amount_dispensed = amount
+ end
+
+ def last_amount_dispensed
+ @last_amount_dispensed || raise("I am empty!")
end
end
class Account
def balance
- 450
+ end
+end
+
+class Teller
+ def initialize(cash_dispenser)
+ @cash_dispenser = cash_dispenser
+ end
+
+ def authenticate_as(account)
+ end
+
+ def withdraw(amount)
+ @cash_dispenser.dispense(amount)
end
end
@@ -35,15 +51,23 @@ def create_account(balance)
end
def withdraw(amount)
+ teller.authenticate_as(my_account)
+ teller.withdraw(amount)
end
def cash_dispenser
- CashDispenser.new
+ @cash_dispenser ||= CashDispenser.new
end
def my_account
Account.new
end
+
+ private
+
+ def teller
+ Teller.new(cash_dispenser)
+ end
end
World(DomainDriver)

No commit comments for this range

Something went wrong with that request. Please try again.