Specifying Content Type in rspec

Viewed 20463

I'm trying to build an rspec test that sends JSON (or XML) via POST. However, I can't seem to actually get it working:

    json = {.... data ....}.to_json
    post '/model1.json',json,{'CONTENT_TYPE'=>'application/json'}

and this

    json = {.... data ....}.to_json
    post '/model1.json',json,{'Content-Type'=>'application/json'}

any ideas? THANKS!

8 Answers
@request.env["CONTENT_TYPE"] = "application/json"

OR pass in request

"CONTENT_TYPE" => "application/json"

Related