Skip to content
Browse files

let() demos

  • Loading branch information...
1 parent 50dcf98 commit ec2a407564d7a6cd5d954ddd97ca85129eb89a09 @dchelimsky committed Oct 13, 2009
Showing with 9 additions and 38 deletions.
  1. +6 −4 code/let/demo/before_example.rb
  2. +2 −2 code/let/demo/let_example.rb
  3. +1 −32 code/let/let_example.rb
View
10 code/let/demo/before_example.rb
@@ -10,15 +10,17 @@ def withdraw(amount, currency)
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
- account = Account.new(10, :BRL)
- expect { account.withdraw(11, :BLR) }.
+ 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) }.
+ expect { @account.withdraw(10, :BLR) }.
to_not raise_error
end
end
View
4 code/let/demo/let_example.rb
@@ -10,14 +10,14 @@ def withdraw(amount, currency)
describe Account do
context "with 10 BLR" do
+ let(:account) { Account.new(10, :BRL) }
+
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
end
View
33 code/let/let_example.rb
@@ -22,35 +22,4 @@ def withdraw(amount, currency)
to_not raise_error
end
end
-end
-
-# describe Account do
-# context "with 10 BLR" do
-# before(:each) { @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
-# 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
-# end
-# end
-# end
-#
+end

0 comments on commit ec2a407

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