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 -- 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.
On 24 May 2011 04:26, satyamag <satyamag at 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 at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110524/d12f94ea/attachment.html>
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 <apremdas at gmail.com> wrote:> On 24 May 2011 04:26, satyamag <satyamag at 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 at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > -- > ------------------------ > Andrew Premdas > blog.andrew.premdas.org > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
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 <ckponnappa at 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 <apremdas at gmail.com> wrote: >> On 24 May 2011 04:26, satyamag <satyamag at 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 at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> -- >> ------------------------ >> Andrew Premdas >> blog.andrew.premdas.org >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >
It was simple enough to add to Rails - I''ve submitted a pull request: https://github.com/rails/rails/pull/1277 If the pull request isn''t accepted, then it should be easy enough for me to add it to rspec-rails if David and the rest of the rspec team thinks that''s an acceptable alternative. Best, Sidu. http://c42.in http://about.me/ponnappa On 24 May 2011 23:54, Sidu Ponnappa <ckponnappa at gmail.com> wrote:> 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 <ckponnappa at 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 <apremdas at gmail.com> wrote: >>> On 24 May 2011 04:26, satyamag <satyamag at 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 at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >>> >>> -- >>> ------------------------ >>> Andrew Premdas >>> blog.andrew.premdas.org >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >
On 24 May 2011 19:13, Sidu Ponnappa <ckponnappa at 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 > >Ah do you have any links about this you would recommend? Always something new to learn All best Andrew> 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 <apremdas at gmail.com> wrote: > > On 24 May 2011 04:26, satyamag <satyamag at 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 at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -- > > ------------------------ > > Andrew Premdas > > blog.andrew.premdas.org > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110524/9530903c/attachment.html>
Take a look at http://tech.groups.yahoo.com/group/rest-discuss/message/13468 http://tech.groups.yahoo.com/group/rest-discuss/message/13319 http://tech.groups.yahoo.com/group/rest-discuss/message/17014 There''s more, but these were the ones I could find quickly. Best, Sidu. http://c42.in http://about.me/ponnappa On 25 May 2011 00:55, Andrew Premdas <apremdas at gmail.com> wrote:> > > On 24 May 2011 19:13, Sidu Ponnappa <ckponnappa at 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 >> > > Ah do you have any links about this you would recommend? Always something > new to learn > All best > Andrew > >> >> ?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 <apremdas at gmail.com> wrote: >> > On 24 May 2011 04:26, satyamag <satyamag at 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 at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > >> > >> > >> > -- >> > ------------------------ >> > Andrew Premdas >> > blog.andrew.premdas.org >> > >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-users at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/rspec-users >> > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > -- > ------------------------ > Andrew Premdas > blog.andrew.premdas.org > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >