这是我的 rspec 代码:-
it "should match with valid address" do
get :index, Devise.token_authentication_key => @user.authentication_token, business_id: @business2.id
expect(response.status).to eq(200)
expect(response.body).to eq([@location].to_json(LocationFinder::API_PARAMS.merge(:root => false)))
end
预期的:
"[
{
\"address\":\"1120 Milky Way\",
\"business_id\":1,
\"city\":\"Cupertino\",
\"latitude\":\"2.4\",
\"longitude\":\"2.9\",
\"name\":\"Joe's Diner\"
}
]"
得到:
"[
{
\"address\":\"1120 Milky Way\",
\"business_id\":1,
\"city\":\"Cupertino\",
\"latitude\":\"2.4\",
\"longitude\":\"2.9\",
\"name\":\"Joe's Diner\",
\"distance\":712.7948793
}
]"
如何将“距离”字段删除到包含哈希值的数组中。所以我的测试会成功。