我在Rails控制器问题中有以下模块:
var formData=new FormData();
formData.append("obj1",new Blob([JSON.stringify(obj1)],{type: "application/json"}));
formData.append("obj2",new Blob([JSON.stringify(obj2)],{type: "application/json"}));
http({
method: 'POST',
url: '/MyProject/requestUrl',
headers: { 'Content-Type': undefined},//to set boundary value by default
data: formData,
})
目前,把cognito_user返回:
@RequestMapping(value = { "/requestUrl" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST)
@ResponseBody
public String getRequest(@RequestPart("obj1") Object1 object1,
@RequestPart("obj2") Object2 Object2,HttpSession session)
throws IOException {
//implementation
}
如何在Rspec中调整响应,以便username和user_attributes不是nil?
答案 0 :(得分:0)
在玩了yzalavin的建议之后......以下对我有用......
allow_any_instance_of( AwsAuth )
.to receive(:get_cognito_user)
.and_return( JSON[ {email: "testy@example.com"}.to_json ] )