[rspec-users] attributes method not working?
rick.denatale at gmail.com
Thu Nov 27 15:30:14 EST 2008
On Thu, Nov 27, 2008 at 11:03 AM, David Chelimsky <dchelimsky at gmail.com>wrote:
> On Thu, Nov 27, 2008 at 9:06 AM, <rspec-users at jfrankov.otherinbox.com>
> > it "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.
> > @adtag.errors.on(:size).should eql("is not included in the list") #
> > @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.
My blog on Ruby
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users