I am trying to create a mock object
and i am checking whether my method receives
the right param
and expected result.
Below is my spec
.
require 'spec_helper'
describe User do
let(:username) {"test@test.com"}
let(:password) {"123"}
let(:code) {"0"}
context "when signing in" do
it "should sign in" do
user = double("user")
expected_results = {
"token": "123"
}
allow(user).to receive(:login).with({email: username, password: password, code: code})
.and_return(expected_results)
expect(user.login).to eq(expected_results)
end
end
end
Is there a way to separate my json
from it
block and keep it outside?.