On Jan 14, 2012, at 10:32 AM, David Chelimsky wrote:

> On Jan 14, 2012, at 8:40 AM, apneadiving wrote:
> 
>> As I am writing a brand new API, I'd like to test it's response.
> <snip/>
>> Basically, it would be great in my case to test if ActiveResource gets
>> the expected data but it means I have to launch a test server in
>> background for the whole suite.
> <snip/>
>> Is there a convenient to handle this? Currently, I launch the test
>> server in console but it would be much better to have this handled
>> programmatically.
> 
> I'd recommend you check out https://github.com/brynary/rack-test. It provides 
> access to attributes of the request and the response object, and obviates the 
> need for running a server. Take a look at its specs: 
> https://github.com/brynary/rack-test/blob/master/spec/rack/test_spec.rb.

Of course, you get rack-test for free if you use request specs (which wrap 
Rails integration tests, which use rack-test).

http://rubydoc.info/gems/rspec-rails/file/README.md#Request_Specs
http://guides.rubyonrails.org/testing.html#integration-testing



_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to