I'm under the weather so I won't be able to give you a thorough answer. #let - The block is executed when you call it. #let! - The block is "wrapped" in a before(:each) filter.
So, you want to use #let! On Nov 2, 7:55 pm, Nadal <[email protected]> wrote: > Here is my test which passes. > > before do > @page = Factory(:page) > @note = Factory(:note, :page => @page, :title => 'super cool') > end > it 'has size 1' do > @page.notes.size.should == 1 > end > > I read rspec book and wanted to use let. Here is my implementation. > And it fails > > let(:page) { Factory(:page) } > let(:note) { Factory(:note, :page => page, :title => 'super > cool') } > it 'has size 1' do > page.notes.size.should == 1 > end > > In the log I noticed that when I switched to using let then no note > record is being created. > > Here is relevant gem file > > group :development, :test do > gem 'mongrel' > gem 'capistrano', ">= 2.5.19" > gem 'capistrano-ext' > > gem "factory_girl_rails" > > gem "database_cleaner" > gem "shoulda" > > gem "rspec-rails", ">= 2.0.1" > gem "cucumber-rails", ">= 0.3.2" > gem "capybara", "= 0.4.0" > gem "launchy" > gem "redgreen" > gem "faker" > gem "mongrel" > end > > Is let lazy? It seems since I am not using note the record is not > being created. > > The book said that output is memoized. Nothing more than that. > _______________________________________________ > rspec-users mailing list > [email protected]http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
