Skip to content

Instantly share code, notes, and snippets.

@amitpatelx
Created March 16, 2012 09:15
Show Gist options
  • Save amitpatelx/2049246 to your computer and use it in GitHub Desktop.
Save amitpatelx/2049246 to your computer and use it in GitHub Desktop.
use let to define memoized helper method
$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