[rspec-users] attributes method not working?

Rick DeNatale 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>
> wrote:
> >   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.

Rick DeNatale

My blog on Ruby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081127/627426e9/attachment.html>

More information about the rspec-users mailing list