On Wed, Nov 26, 2008 at 4:08 AM, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > OK, I can't figure this out. > RSpec 1.1.8 > RSpecRails 1.1.8 > Rails 2.1.1 > I have a model > #app/models/person.rb > class Person < ActiveRecord::Base > # The model has a lot of code in it, but even deleting > # all the contents down to an empty model like this > # still produces the error > end > #app/observers/person_observer.rb > class PersonObserver < ActiveRecord::Observer > def before_save(person) > Note.update_associated(person) > end > end > #config/environment.rb > ... > config.activerecord.observers = [:person_observer, ...] > The observer is not being called using > #spec/observers/person_observer_spec.rb > describe PersonObserver do > it "should call the observer" > person = Person.generate > Note.should_receive(:update_associated) > person.save > end > it "should not call the observer" > person = Person.generate > Note.should_receive(:update_associated) > person.save > end > end > This fails, and I can not figure out why.
I see two examples with identical code. Do they both fail, or just the 2nd one? If so, there was a bug in which mocked inherited class methods were not properly restored after the example. This is fixed in git, but not released. Would you mind building the gem from the latest and see if it resolves your issue? Thanks, David > > If I fire up the console and modify a person and save it, the observer fires > and the Note class updates what it needs to. > But the cracker is.... I have other observers that work fine.... I'm at wits > end on this. > Any ideas why the observer might not be called? > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > > > > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
