Is there a nicer way to set POST body data in rspec on rails?
Than开发者_开发百科 request.env['RAW_POST_DATA'] = json_body
?
I'm not sure if this is what you mean, but you can set the request headers to indicate 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
精彩评论