Skip to content
Browse files

demo files for 'let' example

  • Loading branch information...
1 parent 5a00204 commit e85319bf4a951b6b181eb7d455aa57004264869e @dchelimsky committed Oct 10, 2009
Showing with 50 additions and 57 deletions.
  1. +25 −0 code/let/demo/before_example.rb
  2. +25 −0 code/let/demo/let_example.rb
  3. +0 −57 code/let/let_example_live.rb
View
25 code/let/demo/before_example.rb
@@ -0,0 +1,25 @@
+require 'account'
+
+class InsufficientFunds < StandardError; end
+
+class Account
+ def withdraw(amount, currency)
+ raise InsufficientFunds.new if amount > 10
+ end
+end
+
+describe Account do
+ context "with 10 BLR" do
+ it "denies a withdrawal of 11 BLR" do
+ account = Account.new(10, :BRL)
+ expect { account.withdraw(11, :BLR) }.
+ to raise_error(InsufficientFunds)
+ end
+
+ it "allows a withdrawal of 10 BLR" do
+ account = Account.new(10, :BRL)
+ expect { account.withdraw(10, :BLR) }.
+ to_not raise_error(InsufficientFunds)
+ end
+ end
+end
View
25 code/let/demo/let_example.rb
@@ -0,0 +1,25 @@
+require 'account'
+
+class InsufficientFunds < StandardError; end
+
+class Account
+ def withdraw(amount, currency)
+ raise InsufficientFunds.new if amount > 10
+ end
+end
+
+describe Account do
+ context "with 10 BLR" do
+ it "denies a withdrawal of 11 BLR" do
+ account = Account.new(10, :BRL)
+ expect { account.withdraw(11, :BLR) }.
+ to raise_error(InsufficientFunds)
+ end
+
+ it "allows a withdrawal of 10 BLR" do
+ account = Account.new(10, :BRL)
+ expect { account.withdraw(10, :BLR) }.
+ to_not raise_error(InsufficientFunds)
+ end
+ end
+end
View
57 code/let/let_example_live.rb
@@ -1,57 +0,0 @@
-require 'account'
-
-class InsufficientFunds < StandardError; end
-
-class Account
- def withdraw(amount, currency)
- raise InsufficientFunds.new if amount > 10
- end
-end
-
-describe Account do
- context "with 10 BLR" do
- it "denies a withdrawal of 11 BLR" do
- account = Account.new(10, :BRL)
- expect { account.withdraw(11, :BLR) }.
- to raise_error(InsufficientFunds)
- end
-
- it "allows a withdrawal of 10 BLR" do
- account = Account.new(10, :BRL)
- expect { account.withdraw(10, :BLR) }.
- to_not raise_error(InsufficientFunds)
- end
- end
-end
-
-describe Account do
- context "with 10 BLR" do
- before(:each) do
- @account = Account.new(10, :BRL)
- end
- it "denies a withdrawal of 11 BLR" do
- expect { @account.withdraw(11, :BLR) }.
- to raise_error(InsufficientFunds)
- end
-
- it "allows a withdrawal of 10 BLR" do
- expect { @account.withdraw(10, :BLR) }.
- to_not raise_error(InsufficientFunds)
- end
- end
-end
-
-describe Account do
- context "with 10 BLR" do
- let(:account) { Account.new(10, :BRL) }
- it "denies a withdrawal of 11 BLR" do
- expect { account.withdraw(11, :BLR) }.
- to raise_error(InsufficientFunds)
- end
-
- it "allows a withdrawal of 10 BLR" do
- expect { account.withdraw(10, :BLR) }.
- to_not raise_error(InsufficientFunds)
- end
- end
-end

0 comments on commit e85319b

Please sign in to comment.
Something went wrong with that request. Please try again.