Of course, it is important to note that Rails also supports a few other http verbs in addition to get: post, put and delete.<br><br>I really think rspec will be the ideal vehicle for Rails integration tests, once it is mature. I look forward to the day I can start a new application by writing high-level integration specs, and then see those tests pass as I stitch together the controllers and models.
<br><br>Chris<br><br><div><span class="gmail_quote">On 10/28/06, <b class="gmail_sendername">Jeff Dean</b> &lt;<a href="mailto:jeff@jefdean.com">jeff@jefdean.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It looks like there's another way to do this in rails I just found in AWDWR:<br><br>xhr(:get, :add_to_cart, :id =&gt; 11)<br><br>I'm not sure if there are other methods like xml() etc... but that looks easier than the example I provided below.
<div><span class="e" id="q_10e91d1661f7794d_1"><br><br><div><span class="gmail_quote">On 10/28/06, <b class="gmail_sendername">Jeff Dean</b> &lt;<a href="mailto:jeff@jefdean.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
jeff@jefdean.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for the quick reply - <br><br>I would be looking for a way to easily specify the most common types in shorthand, but have the ability to specify full HTTP headers if I want to.&nbsp; Ideally I would look for a third parameter in the get/post/put/delete methods that accepts a hash of http headers like 
<a href="http://api.rubyonrails.org/classes/ActionController/Integration/Session.html#M000083" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://api.rubyonrails.org/classes/ActionController/Integration/Session.html#M000083
</a>.&nbsp; The spec might look like:<br><br><pre><span>context</span> <span>&quot;</span><span>A get to /index</span><span>&quot;</span> <span>do</span><span></span><br><br>  <span>
specify</span> <span>&quot;</span><span>from a browser should show html</span><span>&quot;</span> <span>do</span><br>    get :index<br>    # should statements... &nbsp;<br><span></span><br>&nbsp;<span> end</span><br><br>  <span>specify
<br></span> <span>&quot;</span><span>in xml format should render xml</span><span>
&quot;</span> <span>do</span><br>    get :index, {}, {:content_type=&gt;'application/xml', :accept =&gt; 'application/xml'}<br>    # should statements... &nbsp;<span><br>  end</span><br><br><span>
end</span>
</pre>It seems like the convention in rails right now is to request rss and atom feeds by using the .rss/.atom extensions and changing the 'accepts' header in application.rb - so that leaves us with 4 fairly standard request types: html, javascript, xml and mobile devices (which I know little about).&nbsp; Since these will be so common, some syntactic sugar would be nice as well - maybe something like:
<br><pre><span>context</span> <span>&quot;</span><span>A get to /index</span><span>&quot;</span> <span>do</span><span></span><br><br>
  <span>specify</span> <span>&quot;</span><span>from an ajax call should render rjs</span><span>&quot;</span> <span>do</span><br>    get :index, {}, :format =&gt; :js # where the magic word 'format' correctly sets the accept header
<br><br><span><br></span>    # should statements... &nbsp;<span></span><br><span>  end</span><span style="font-family: arial,sans-serif;"><br><br>end<br></span></pre>
References:<br>

<ul><li><a href="http://www.loudthinking.com/arc/000572.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.loudthinking.com/arc/000572.html</a></li></ul>I'd love to see these generators and plugins become part of core, too.&nbsp; After working with RSpec for a few days now, I doubt I'll ever go back to the unit and functional tests.&nbsp; Thanks for the hard work - 
<br><span><br>Jeff</span><div><span><br><br><br><div><span class="gmail_quote">On 10/28/06, <b class="gmail_sendername">David Chelimsky</b> &lt;<a href="mailto:dchelimsky@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

dchelimsky@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 10/28/06, Jeff Dean &lt;<a href="mailto:jeff@jefdean.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jeff@jefdean.com</a>&gt; wrote:<br>&gt; Is anyone using RSpec with RESTful rails apps?&nbsp;&nbsp;In my rails controllers I
<br>&gt; check request.respond_to? and render different views accordingly.
<br>&gt;<br>&gt; I noticed that the get method in the rails plugin doesn't accept headers:<br>&gt;<br>&gt; controller_mixin.rb line 92<br>&gt; def get(action, parameters = nil)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @request.env['REQUEST_METHOD'] = 'GET'
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; process action, parameters<br>&gt; end<br>&gt;<br>&gt; Has anyone found a way around this?<br><br>Hi Jeff. We're getting ready to release a new version of the plugin so<br>now is a good time to at least consider addressing this. Can you write
<br>an example of how you'd want to be able to write the spec (and<br>controller code) for a restful get request? Don't worry about how<br>rspec would do it. I just want to know what you want it to do.<br><br>Thanks,<br>

David
<br><br>&gt;<br>&gt; Jeff<br>&gt;<br>&gt; _______________________________________________<br>&gt; Rspec-users mailing list<br>&gt; <a href="mailto:Rspec-users@rubyforge.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

Rspec-users@rubyforge.org</a><br>&gt; <a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br>&gt;<br>&gt;<br>_______________________________________________<br>Rspec-users mailing list<br><a href="mailto:Rspec-users@rubyforge.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

Rspec-users@rubyforge.org</a>
<br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br>

</span></div></blockquote></div><br>

</span></div><br>_______________________________________________<br>Rspec-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Rspec-users@rubyforge.org">Rspec-users@rubyforge.org</a>
<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br><br></blockquote></div><br><br clear="all">
<br>-- <br>Chris Anderson<br><a href="http://mfdz.com/jchris">http://mfdz.com/jchris</a>