A cursory examination of http://apidock.com/rails/ActionController/TestCase seems to indicate that there may be no way to write tests for options calls using standard Rails tests. 'First, one uses the get, post, put, delete or head method to simulate an HTTP request.'
Best, Sidu. http://c42.in http://about.me/ponnappa On 24 May 2011 23:43, Sidu Ponnappa <ckponna...@gmail.com> wrote: > Hi Andrew, > > I'm not sure that's necessarily true - I've read of several RESTful > APIs using OPTIONS to discover more about a resource at a URI. Rails > clearly recognizes the OPTIONS HTTP verb because I get > > Started OPTIONS "/" for 127.0.0.1 at Tue May 24 23:38:38 +0530 2011 > > when I query a standard Rails index action from an interactive console: > Ruby 1.9.2, 2011-02-18, x86_64-darwin10.6.0 > Loading Wrest 1.4.4 > ruby-1.9.2-p180 :001 > response = 'http://localhost:3000'.to_uri.options > <- (OPTIONS -2038453369797053398 -4029552566690348382) http://localhost:3000/ > -> (OPTIONS -2038453369797053398 -4029552566690348382) 200 OK (0 bytes 0.09s) > => #<Wrest::Native::Response:0x00000100d89ea0 > @http_response=#<Net::HTTPOK 200 OK readbody=true>> > ruby-1.9.2-p180 :002 > response.body > => nil > > Interestingly, that same uri does actually have a body when invoked with a > get. > > Best, > Sidu. > http://c42.in > http://about.me/ponnappa > > > On 24 May 2011 23:07, Andrew Premdas <aprem...@gmail.com> wrote: >> On 24 May 2011 04:26, satyamag <satya...@gmail.com> wrote: >>> >>> Hi >>> >>> I am new to rails and rspec. I am trying to write specs for a web service >>> written in rails and found that firefox 3.6 makes an OPTIONS call to the >>> server before making a POST. >>> >>> I want to write a spec for this behavior but am unable to find any >>> resource >>> on how to write a spec for an OPTIONS call. Could someone please help? I >>> would really appreciate it. >>> >>> I am working on rails 3 with ruby 1.9.2 and rspec 2.5.2 >>> >>> thank you >> >> Do you really need to do this? From my cursory look of the w3 spec >> http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html, the options command >> is all about establishing comms with your server - not your service. So >> there is nothing to specify in your service is there! Your not writing >> specs for apache, nginx or whatever you have serving your application. >> HTH, and if I'm wrong please let me know >> All best >> Andrew >> >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/Writing-a-spec-for-HTTP-OPTIONS-verb-tp31687138p31687138.html >>> Sent from the rspec-users mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users@rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> ------------------------ >> Andrew Premdas >> blog.andrew.premdas.org >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users@rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users