比request.env['RAW_POST_DATA'] = json_body
?
答案 0 :(得分:10)
我不确定这是不是您的意思,但您可以设置请求标头以指示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