1

I'm trying to test my controller but my controller accept request payload for the whole json string which I can't seem to figure out how to set it in RSpec.

Here's my RSpec code


xit "should update favourite movies" do
      rack_mock_session.cookie_jar["auth_token"] = "1"

      put '/user', :params => {:movie => "1}.to_json
      last_response.should be_ok

end

And this is my controller code


  raw = request.env["rack.input"].read
  raw_json = JSON.parse(raw)

  movie_id = raw_json["movie"]
  ...

But it doesn't work.

4

0 回答 0