nebulab / simple_command

A simple, standardized way to build and use Service Objects (aka Commands) in Ruby
http://nebulab.it
MIT License
625 stars 55 forks source link

How mock with rspec with prepended SimpleCommand #31

Closed Xeej closed 3 years ago

Xeej commented 3 years ago
before do
  allow_any_instance_of(Class).to receive(:call).and_return(double)
end

Failure/Error: allow_any_instance_of(Class).to receive(:call).and_return(double) Using any_instance to stub a method (call) that has been defined on a prepended module (SimpleCommand) is not supported.

Xeej commented 3 years ago

Use this

before do
  allow(Class).to receive(:call).and_return(double)
end