Skip to content

Instantly share code, notes, and snippets.

@timruffles
Created January 9, 2015 18:04
Show Gist options
  • Save timruffles/4f1cca991acfb175ed57 to your computer and use it in GitHub Desktop.
Save timruffles/4f1cca991acfb175ed57 to your computer and use it in GitHub Desktop.
rails - POST JSON in controller tests in rails 3.2.x - can't easily do it, necessary for things as simple as post body containing { action: "something" }
# from http://stackoverflow.com/a/13206873/427710
env = Rack::MockRequest.env_for('/posts/1', :method => 'PUT', <some other params>)
status, headers, body = PostsController.action(:update).call(env)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment