I\'m looking to send raw post data (e.g. unparamaterized JSON) to one of my controllers for testing:
class LegacyOrderUpdateControllerTest < ActionControl
I actually solved the same issues just adding one line before simulating the rspec post request. What you do is to populate the "RAW_POST_DATA". I tried to remove the attributes var on the post :create, but if I do so, it do not find the action.
Here my solution.
def do_create(attributes) request.env['RAW_POST_DATA'] = attributes.to_json post :create, attributes end
In the controller the code you need to read the JSON is something similar to this
@property = Property.new(JSON.parse(request.body.read))