开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜