Thanks all for excellent pointers!
On Feb 8, 2008 2:21 AM, Jarkko Laine <[EMAIL PROTECTED]> wrote: > On 8.2.2008, at 1.26, Pito Salas wrote: > > > I am experimenting with the restful-authentication plug in and I see > > that it has generated an rspec encantation which I had not seen > > before: > > > > it 'allows signup' do > > lambda do > > create_user > > response.should be_redirect > > end.should change(User, :count).by(1) > > end > > > > What does the combination of a lambda and a .should mean? > > Lambda is an anonymous function, or pretty much the same as a block of > code. So in the case above, running the code inside the lambda block > should change the user count by one. This is the same as > assert_difference does in test/unit. > > > > > > > Similarly but a little different: > > > > describe 'being created' do > > before do > > @user = nil > > @creating_user = lambda do > > @user = create_user > > violated "[EMAIL PROTECTED]" if > > @user.new_record? > > end > > end > > > > it 'increments User#count' do > > @creating_user.should change(User, :count).by(1) > > end > > end > > > > Thanks for any pointers or clarifications! > > Same thing, just this time the function is first stored in an instance > variable. > > //jarkko > > -- > Jarkko Laine > http://jlaine.net > http://dotherightthing.com > http://www.railsecommerce.com > http://odesign.fi > > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users