Guest User

Untitled

a guest
May 20th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. RSpec.configure do |config|
  2. # ...
  3.  
  4. config.prepend(
  5. Module.new do
  6. %i[get post patch put delete head].each do |method|
  7. params_snippet = method.in?(%i[post patch put]) ? "args[:params] = args[:params].to_json" : ""
  8. module_eval <<~RUBY, __FILE__, __LINE__ + 1
  9. def #{method}(path, **args)
  10. if args.present? && args.values.none? { |v| v.is_a?(Rack::Test::UploadedFile) }
  11. #{params_snippet}
  12. args[:headers] = (args[:headers] || {}).merge("CONTENT_TYPE" => "application/json")
  13. end
  14. super(path, **args)
  15. end
  16. RUBY
  17. end
  18. end,
  19. type: :request,
  20. )
  21.  
  22. # ...
  23. end
Add Comment
Please, Sign In to add comment