Gernot Kogler
2006-May-25 10:08 UTC
[Rails] Help: How to write tests for a sms service interface
I''m working on a website that integrates sms services. When someone sends an sms to my service number, the sms provider posts an xml doc to an url specified by me. I have implemented the processing method like this: <code> def process_notification xml = XmlSimple.xml_in(@request.raw_post, ''ForceArray'' => false) @params.merge! xml sms_request = SmsboxRequest.new(:phonenumber => @params["sender"], :operator => @params["operator"], :service => @params["service"], :message => @params["message"]) sms_request.save end </code> I have tested this method with a test application provided by my sms provider and all works like a charm. Now I want to write a functional test for this controller, but I don''t know how to build a post request that works. How am I supposed to call post so that my xml document is in the raw_post of my TestRequest ? I tried this: post :process_notification, xml post :process_notification, {:params => xml} post :process_notification, {:id => xml} where xml contains a valid xml document but none of them work. Any help is more than welcome ! -- Posted via http://www.ruby-forum.com/.
Hi, Which sms provider are you using ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
apsoto-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-19 22:22 UTC
Re: Help: How to write tests for a sms service interface
Are you testing the implementation or just your code''s interaction with the interface? If you''re testing the interaction, then mock the interface. http://rubyforge.org/projects/mocha On Feb 18, 9:36 pm, Rm Rm <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > Which sms provider are you using ? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---