On 17/08/2009, at 10:45 AM, MarkBennett wrote:
> What is the right way to do this in rails?  What testing tools should
> I be using?

There are plenty of testing frameworks you can layer on top of the  
most basic tests, but in general terms you're going to be writing  
integration tests. It will look a little something like this:

>    class SomeControllerTest < ActionController::IntegrationTest
>      def test_response_has_correct_json_content_type
>        get '/some/action.json'
>        assert 'application/x-json', response.content_type
>      end
>      def test_response_conforms_to_google_vis_wire_protocol
>        get '/some/action.json'
>        # run some checks on response.body, perhaps
>        #  using JsonPath (XPath for JSON)
>      end
>    end

If your SomeController#action does some smart stuff you don't really  
need to test, you'll need to look into stubbing the methods your  
action is calling by using a mocking/stubbing framework. Once you've  
got your tests working, then you can start to look into other test  
frameworks that provide a little bit of extra syntax-sugar/convenience.

Hope that helps!


Cheers,

Nathan de Vries

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to