On 12/13/07, Rick DeNatale <[EMAIL PROTECTED]> wrote:
> On 12/13/07, David Chelimsky <[EMAIL PROTECTED]> wrote:

> > This is a bit scary :(
> >
> > Rick - would you mind sticking this information, a bit filtered, into
> > the tracker?
>
> Well, as I was doing just that, I looked a bit closer at those
> walkbacks, and it occurred to me that I was assuming that rspec was
> calling the method twice.
>
> As it turns out, it was actually ActiveRecord calling the callback
> twice, and it went away when I changed from
>
> after_create do |msg|
>    ...
> end
>
> to
>
> def after_create
>    ...
> end
>
> So I guess I need to follow up on Rails core!  Although that change
> fixed things for this case.

Okay,  more info.  As I was investigating this for a possible ticket
for Rails Trac, it dawned on me that maybe, just maybe, the
after_create do...end was being executed twice.  So I added a puts
"**** loading Message" in the class definition for the Message AR
class, and sure enough it was being loaded twice!

It turns out that I had

require 'message'

at the top of the spec file. and a few other descriptions in the same
file which were using the messages fixture.

When I remove the require 'message' from my spec file, it seems to
work with either form of the callback definition.

So I'm not sure if this is an Rspec bug, an AR fixtures bug, both or
neither. <G?>
-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to