So far I''ve been manually using curl to make get and post requests against my Rails app to see if I''m responding to XML clients correctly. But this is silly, I need to write unit tests. I don''t see an obvious way to do this in Rails unit tests. I''m about to invent an ''xml_fixtures'' helper method that will pull in some hardcoded XML files, and then use those to make post requests and/or make sure I get the expected XML back from the server. But before I invest the time - is there a better way? Thanks Jeff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can do it with integration tests, but I agree that there ought to be a lower-level approach On 16 Apr 2007, at 17:16, Jeff wrote:> > So far I''ve been manually using curl to make get and post requests > against my Rails app to see if I''m responding to XML clients > correctly. > > But this is silly, I need to write unit tests. I don''t see an obvious > way to do this in Rails unit tests. I''m about to invent an > ''xml_fixtures'' helper method that will pull in some hardcoded XML > files, and then use those to make post requests and/or make sure I get > the expected XML back from the server. > > But before I invest the time - is there a better way? > > Thanks > Jeff > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
----------------------------------------------------- get(path, parameters=nil, headers=nil) Performs a GET request with the given parameters. The parameters may be nil, a Hash, or a string that is appropriately encoded (application/ x-www-form-urlencoded or multipart/form-data). The headers should be a hash. The keys will automatically be upcased, with the prefix ''HTTP_'' added if needed. You can also perform POST, PUT, DELETE, and HEAD requests with post, put, delete, and head. ----------------------------------------------------- You can use all the REST verbs from within your functional and integration tests. You should be able to set your ACCEPTS header to have the call return whatever format you want to test against. On Apr 16, 12:16 pm, "Jeff" <cohen.j...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So far I''ve been manually using curl to make get and post requests > against my Rails app to see if I''m responding to XML clients > correctly. > > But this is silly, I need to write unit tests. I don''t see an obvious > way to do this in Rails unit tests. I''m about to invent an > ''xml_fixtures'' helper method that will pull in some hardcoded XML > files, and then use those to make post requests and/or make sure I get > the expected XML back from the server. > > But before I invest the time - is there a better way? > > Thanks > Jeff--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This really doesn''t make sense to be available from unit tests. The format that is returned is controlled by the controller class, not the model, so the proper place to test this is in functional and/or integration test. On Apr 16, 12:40 pm, Jonathan del Strother <maill...-3GLpx8vVthx0ubjbjo6WXg@public.gmane.org> wrote:> You can do it with integration tests, but I agree that there ought to > be a lower-level approach > > On 16 Apr 2007, at 17:16, Jeff wrote: > > > > > So far I''ve been manually using curl to make get and post requests > > against my Rails app to see if I''m responding to XML clients > > correctly. > > > But this is silly, I need to write unit tests. I don''t see an obvious > > way to do this in Rails unit tests. I''m about to invent an > > ''xml_fixtures'' helper method that will pull in some hardcoded XML > > files, and then use those to make post requests and/or make sure I get > > the expected XML back from the server. > > > But before I invest the time - is there a better way? > > > Thanks > > Jeff--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---