开发者

Is there a nicer way to set POST body data in rspec on rails?

开发者 https://www.devze.com 2023-02-12 23:33 出处:网络
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:

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

精彩评论

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