比request.env [‘RAW_POST_DATA’] = json_body?
我不知道这是否是您的意思,但您可以设置请求标头来表示
JSON:
describe "POST 'create'" do
it "should be successful" do
request.env["HTTP_ACCEPT"] = "application/json"
post 'create',:article => { :title => "Foo" }.to_json
response.should be_success
end
end
原文链接:https://www.f2er.com/ruby/266543.html