Reputation: 4272
Ive seen mentions of curl here and there on rails blogs and ive scanned some posts here on stackoverflow but im still a bit in the dark as to its use especially when it comes to rails development.
Is it useful for testing? Im currently learning the ins and outs of testing and one of the things i need to do is test a before filter that only allows an action to be called if the user came from a certain external site. Is this an occasion where curl would be used?
Upvotes: 4
Views: 3879
Reputation: 58014
Ruby (Rail?) hackers might also be interested in one of the many Ruby bindings for libcurl, the library that powers the curl tool. Like them mentioned here: http://curl.haxx.se/libcurl/ruby/
Upvotes: 0
Reputation: 115362
Have a look at hurl—which is written in Rails—and then imagine a more powerful command-line version. That's pretty much cURL.
Upvotes: 1
Reputation: 125167
No, I don't think you'd use cURL for TDD. Using cURL would imply communicating with a remote service, which would be an integration test.
Are you talking about this? http://www.viget.com/extend/curl-and-your-rails-2-app/
In that post, cURL isn't being used in the rails app at all. It's being used on the terminal to test/demo the app's REST service, not in a TDD fashion.
cURL is good for this purpose because its many options allow you to simulate different headers from user agents, such as language acceptance, characterset acceptance, cache usage, etc...
Upvotes: 2
Reputation: 672
curl is a command line program which can retrieve urls, it's quite flexible, for example it can use limited regexes to download a range of files.
You might want to use it for testing, by seeing what happens to your application under certain circumstances, if you want to test what happens if your user comes from a certain site then use the -e option on curl.
The man page is online Here
Upvotes: 5