I got a response from render json: { success: 'Success' }
, I met a problem when I want to test if the response received the content like this. My unit test is:
let(:success) do
{
success: "Success"
}
end
it 'responds with json containing the success message' do
expect(JSON.parse(response.body)).to eq(success)
end
I got a failure from my test, which is:
expected: {:success=>"Success"}
got: {"success"=>"Success"}
I tried to add double quote to success:'Success'
so that it changed to 'success':'Success'
but still have the same problem. I have two questions, the first is why there's a colon before the success, and the second is how could I remove it?
Aucun commentaire:
Enregistrer un commentaire