[rspec-users] stubbing out after_create AR method?
mmazur at gmail.com
Mon Feb 14 18:00:19 EST 2011
On Tue, Feb 15, 2011 at 02:31, Fearless Fool <lists at ruby-forum.com> wrote:
> I have a Premise model with an after_create method, along the lines of:
> class Premise < ActiveRecord::Base
> after_create :etl_attributes
> In production code, etl_attributes accesses the web. For testing I'm
> using WebMock and VCR in cases where I want to test the etl_attributes
> function -- works like a champ.
> For all other tests, I want to create a real Premise object (I need it
> for HABTM associations), but I want to stub out the call to
> etl_attributes. My problem is that I haven't figured out the right way
> to do so. The following DOESN'T work (it should be clear that I'm using
> FactoryGirl as well):
> @premise = Factory.create(:premise)
> ... this still calls etl_attributes and WebMock gets appropriately mad.
> What am I missing?
Perhaps one way to approach this is to have WebMock return an
appropriate success message in response to the network call that
More information about the rspec-users