Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stub static module method on controller

allow_any_instance_of(ServicesController).to receive(A::B.auth(a, b, c, d)).and_return({value: true])

I cannot get my rspec test to mock method A::B.auth.

Using rspec 3 and rails 3.2. Test type: controller.

I want the mock to return a simple hash: {value: true}. Is this possible?

like image 473
Eric Francis Avatar asked Dec 11 '25 10:12

Eric Francis


1 Answers

allow(A::B).to receive(:auth).and_return({value: true})
like image 76
Eric Francis Avatar answered Dec 14 '25 09:12

Eric Francis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!