I have a confusion about how to mock a class method using new expect
syntax.
This works:
Facebook
.should_receive(:profile)
.with("token")
.and_return({"name" => "Hello", "id" => "14314141", "email" => "[email protected]"})
and this doesn't:
facebook = double("Facebook")
allow(facebook).to receive(:profile).with("token").and_return({"name" => "Hello", "id" => "14314141", "email" => "[email protected]"})
Can someone tell me what is wrong here?
Here's what you want to do (no need for double
):
allow(Facebook)
.to receive(:profile)
.with("token")
.and_return({"name" => "Hello", "id" => "14314141", "email" => "[email protected]"})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With