Answer the question
In order to leave comments, you need to log in
How can I force a module method to return what it needs in rspec using the new syntax?
Hello.
RSpec 3.8
Rails 5.2.1
There is a module:
module X
included do
after_create :test_method
end
def test_method
...
end
end
class ParentModel < ApplicationRecord
include X
end
class ChildModel < ApplicationRecord
belongs_to :parent_model
end
parent_model = ParentModel.new
allow(ParentModel).to receive(:new).and_return(parent_model)
allow(parent_model).to receive(:test_method).and_return(true)
child_model = FactoryBot.create(:child_model)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question