[rspec-users] let vs ivar w/ before block
Patrick J. Collins
patrick at collinatorstudios.com
Fri Sep 30 15:48:23 EDT 2011
Am I correct in understanding that the point of using let is that it can
minimize database calls due to memoization?
describe "#something" do
let(:something) = Something.groovy_scope
it "does x" do
something.first.x.should have_coolness
end
it "does y" do
something.first.y.should_not have_coolness
end
end
vs.
describe "#something" do
before :each do
@something = Something.groovy_scope
end
it "does x" do
@something.first.x.should_not have_coolness
end
it "does y" do
@something.first.y.should_not have_coolness
end
end
...
Is that the proper usage?
Patrick J. Collins
http://collinatorstudios.com
More information about the rspec-users
mailing list