I'm putting together a JSON API which may or may not be built with Rails. I'd like to be able to verify that the JSON API is behaving as expected by testing it from a test client that only communicates via HTTP.
For example, the test client will send a request to a given URL on the test server, and then verify that the response is a JSON string equal to what is expected by the specs. The response may also be an HTTP response code such as a 401.
I'm currently running tests with QUnit and jQuery.ajax. It works, but I'm wondering if there's a better option. Has anyone else done something like this?
Thanks!
Any language with a decent HTTP library and a JSON library ought to do. Just pick your favorite language and testing framework and go for it. I'd probably use RSpec and Rack::Test, especially if the API will be implemented in Ruby, but tastes vary.
Edit: You mentioned you'd like to run the tests outside the server. If you're sure about that then use e.g. Net::HTTP instead of Rack::Test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With