0

I ran the below curl command in terminal

curl -d "message" http://localhost:8080/api/validate -u username:password

and is running as expected.

I am writing a functional test for the above in Rails. For doing this I have to call the post method and pass the arguments whatever I have done for curl to post.

post 'validate',:request => "message"

I am able to pass the request paramater successfully. But how do I pass the username and password that I am passing in Curl to the post method in rails. Please advise

bragboy
  • 34,892
  • 30
  • 114
  • 171

1 Answers1

1

The option you are passing to curl is setting up HTTP Basic Auth, so you need to do that in your test.

Take a look at whats going on in the answer to this question:

Testing HTTP Basic Auth in Rails 2.2+

Community
  • 1
  • 1
Chris Cherry
  • 28,118
  • 6
  • 68
  • 71