4

How do I convert the following CURL POST request to rspec controller test file.

The controller#method I test is remote_test#upload

curl -X POST -F report=@readme.md  
-H "X-User-Email: poc.hsu" -H "X-User-Token: WKyi9yAtquCn" 
-H 'X-Test-Token: bpBJHA' 
http://localhost:3000/remote_test/upload
user3675188
  • 7,271
  • 11
  • 40
  • 76

2 Answers2

4

I think that you must do something like:

post "path/to/route", {}, {'HTTP_ACCEPT' => "*/*", 'X-User-Token' => 'user_token_example', 'X-Test-Token' => 'bpBJHA'}

The second parameter is the optional parameters that you could pass to post or get methods.

Best regards!

-3

ruby has system method to execute os commands such as ls, cd etc. Of course including curl. (if the os can have the commnads)

system('curl http://www.yahoo.com')
# => return www.yahoo.com html ...
shoji
  • 490
  • 2
  • 10