ChrisDekker
ChrisDekker

Reputation: 1763

RSpec: stop/stub after_create callback on factory level?

I am writing tests for a model which creates some files and folders on disk in a after_create callback. I would like to skip this in my model tests.

Normally, I would stub these callbacks in the spec which uses the factory, however, this model and factory are used as associations in many different specs. I would not want to repeat these same stubs in all those specs.

How can I set these stubs on the factory level, so I only have to define them once?

Upvotes: 2

Views: 390

Answers (1)

Hubert Jakubiak
Hubert Jakubiak

Reputation: 1013

You can add in spec_helper.rb following code:

config.before(:each) do
  # your stubs
end

Upvotes: 1

Related Questions