On Thu, Feb 12, 2009 at 11:03 AM, Nick Hoffman <n...@deadorange.com> wrote: > Does RSpec automatically call #valid? on ActiveRecord models? > > For instance, when this example is run: > > it 'should reject a nil value' do > @form = TimeShiftForm.new :file => nil > > puts "@form.errors.count = <<#...@form.errors.count}>>" > @form.should have(1).error_on :file > puts "@form.errors.count = <<#...@form.errors.count}>>" > end > > This is printed: > @form.errors.count = <<0>> > @form.errors.count = <<1>> > > However, I never called @form.valid? , which leads me to believe that RSpec > called it for me. > > If RSpec does in fact call #valid? automatically, should we refrain from > manually calling #valid? ?
RSpec doesn't call #valid? automatically in all cases...but if you look at the source for error(s)_on in spec/rails/extensions/active_record/base.rb you'll see that it does call #valid? automatically. Pat _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users