Thanks for the help guys. :) I figured when it started feeling like "hard work" that I was definitely "doing it wrong". :o
Craig... On Fri, Jun 8, 2012 at 9:13 PM, Malcolm Locke <[email protected]> wrote: > On Fri, Jun 08, 2012 at 12:49:08PM +1000, Craig Read wrote: > > How do you guys suggest testing observers via rspec? > > Or should I test the impacts my observers have via cucumber? > > You have probably discovered this already, but I've found observers need > a little voodoo to test directly, something like this: > > describe MymodelObserver do > > # Can't use the default subject, need to set it up like this > subject { MymodelObserver.instance } > > let(:mymodel) { mock_model(Mymodel) } > > describe '#after_save' do > > it "calls heavy_lifting() on the model" do > mymodel.should_receive(:heavy_lifting) > subject.after_save(mymodel) > end > > end > > end > > This doesn't help you much with stubbing your where calls, but I plus > one Dave and Pat's advice on that. > > Malc > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=en. > > -- Craig Read @Catharz https://github.com/Catharz http://stackoverflow.com/users/158893/catharz -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
