rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
On Thu, Nov 27, 2008 at 9:06 AM, [email protected]
wrote:
validates_presence_of :client_id
module AdtagSpecHelperdescribe Adtag do
include AdtagSpecHelperbefore(:each) do
@adtag = Adtag.create( valid_adtag_attributes )
@adtag.should be_valid
endit “should be invalid without an approved size” do
@adtag.attributes = valid_adtag_attributes.except(:size) # ONE
attributes= does NOT set any attributes that are not included in the
hash. In this case it does not try to assign the value of :size.
As for not showing in the test log, I believe (but I’m not sure) that
AR will not run an SQL update unless attributes= changes the value of
any of the attributes it assigns. In this case, that is not happening,
so no query.
Cheers,
David
On Thu, Nov 27, 2008 at 11:03 AM, David C.
[email protected]wrote:
AR will not run an SQL update unless attributes= changes the value of
any of the attributes it assigns. In this case, that is not happening,
so no query.@adtag.errors.on(:size).should eql("is not included in the list") #
TWO
@adtag.should have(1).error_on(:size) # THREE @adtag.should_not be_valid
And since it’s the valid? call which sets the errors, even if you
address
the problems pointed out by David, those errors expectations won’t be
met if
you do things in this order.
–
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/