Created
March 16, 2012 09:15
-
-
Save amitpatelx/2049246 to your computer and use it in GitHub Desktop.
use let to define memoized helper method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$count = 0 | |
describe "let" do | |
let(:count) { $count += 1 } | |
it "memoizes the value" do | |
count.should eq(1) | |
count.should eq(1) | |
end | |
it "is not cached across examples" do | |
count.should eq(2) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment