<div class="gmail_quote">On 27 July 2010 10:17, Riccardo Tacconi <span dir="ltr"><<a href="mailto:rtacconi@gmail.com">rtacconi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I do not get any output with this code<div class="im"><br><br> context "should destroy participation" do<br> setup do<br> @configuration = Factory.create :configuration, :status => 'LIVE'<br>
@p = Factory.create :participation, :configuration => @configuration<br>
@admin = Factory.create :participant, :admin => true<br> login_as @admin<br> end<br><br> should "delete :destroy participations" do<br> assert_difference('Participation.count', -1) do<br>
delete :destroy, :id => @p.to_param<br> end<br> end<br><br></div> app = ApplicationController.new<br> puts app.response.body<div class="im"><br> should_redirect_to("redirect to edit configuration") { edit_configuration_path @configuration }<br>
# should_set_the_flash_to "The host has been unassociated."<br> end<br><br></div>I think the problem is the shoulda context. I am realizing that Shoulda is not so magic and it is complicating my tests instead of helping. Probably I should try Rspec <br>
<div><div></div><div class="h5">
<br></div></div></blockquote><div><br></div><div>You've got that puts in the wrong place. You need to put it inside a should block, for example:</div><div><br></div><div><div class="im"> should "delete :destroy participations" do<br>
app = ApplicationController.new</div><div> puts app.response.body</div><div class="im"> assert_difference('Participation.count', -1) do<br> delete :destroy, :id => @p.to_param<br> end<br>
end<br><br></div></div><div class="im">In terms of complicating your tests or magic, I'd say that Shoulda and Rspec are about equivalent, so switching from one to the other probably won't help.</div><div class="im">
<br></div><div class="im">It may clear things up to know that, basically, those should blocks are defining a test method and setup blocks are defining a setup method and everything not in a should block or setup block is at class-scope for your test case.</div>
<div class="im"><br></div><div>Murray</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div class="h5"><div class="gmail_quote">
On 27 July 2010 09:14, Glenn Gillen <span dir="ltr"><<a href="mailto:glenn@rubypond.com" target="_blank">glenn@rubypond.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div bgcolor="#FFFFFF"><div>Just a "puts response.body" or the equivalent for webrat should be sufficient in your test (before the assertion). </div><div><br></div><div>I suspect Matthews diagnosis is correct, I've been caught by it myself in the past. </div>
<div><br></div><div>Glenn<br><br>- Mistyped in a rush on my mobile</div><div><div></div><div><div><br>On 27 Jul 2010, at 10:09, Riccardo Tacconi <<a href="mailto:rtacconi@gmail.com" target="_blank">rtacconi@gmail.com</a>> wrote:<br>
<br></div><div></div><blockquote type="cite"><div>Matthew,<br><br>I have not used a debugger with Ruby yet.<br><br><div class="gmail_quote">On 26 July 2010 18:21, Matthew Rudy Jacobs <span dir="ltr"><<a href="mailto:matthewrudyjacobs@gmail.com" target="_blank"></a><a href="mailto:matthewrudyjacobs@gmail.com" target="_blank">matthewrudyjacobs@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">have you used debugger?<br>I suggest you see what the content actually looks like<br><br>in particular response.body<br>
<br>perhaps its actually some error page that is being displayed<br>and erroneously returning a 200<br></blockquote><div><br>I think that is the case <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<br>ie.<br>check what your output is exactly<br>before saying the assertion is broken.<br><br></blockquote><div><br>Yes, I am wondering how to intercept the output to have more info<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
most likely its the code thats broken.<div><div></div><div><br><br><div class="gmail_quote">On 26 July 2010 18:17, Riccardo Tacconi <span dir="ltr"><<a href="mailto:rtacconi@gmail.com" target="_blank"></a><a href="mailto:rtacconi@gmail.com" target="_blank">rtacconi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">I do not know if the test sends Accept text/html but I removed respond_to .html and left only the redirect, so it should redirect for every type of content, but I get the same message.<br>
<br>Thanks,<br><font color="#888888"><br>Riccardo</font><div><div></div><div><br><br>
<div class="gmail_quote">On 26 July 2010 18:08, Tim Cowlishaw <span dir="ltr"><<a href="mailto:tim@timcowlishaw.co.uk" target="_blank"></a><a href="mailto:tim@timcowlishaw.co.uk" target="_blank">tim@timcowlishaw.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div><br>
On 26 Jul 2010, at 18:05, Riccardo Tacconi wrote:<br>
<br>
><br>
> Expected response to be a <:redirect>, but was <200><br>
><br>
> But why? That method really return a 302 (redirrect) method. Do I miss something?<br>
<br>
</div>does the request that your test sends have an Accepts header of text/html? Since the redirect is within the respond_to html block, I think it would return 200 for any other content types.<br>
<br>
Cheers,<br>
<br>
Tim<br>
_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank"></a><a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank"></a><a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</blockquote></div><br><br clear="all"><br></div></div><div><div></div><div>-- <br>Riccardo Tacconi<br>Web developer at Wolseley UK <br><br><a href="http://www.linkedin.com/in/riccardotacconi" target="_blank"></a><a href="http://www.linkedin.com/in/riccardotacconi" target="_blank">http://www.linkedin.com/in/riccardotacconi</a><br>
<a href="http://riccardotacconi.blogspot.com/" target="_blank"></a><a href="http://riccardotacconi.blogspot.com/" target="_blank">http://riccardotacconi.blogspot.com/</a><br>
<a href="http://twitter.com/rtacconi" target="_blank"></a><a href="http://twitter.com/rtacconi" target="_blank">http://twitter.com/rtacconi</a><br>Linux user: #400461<br>
</div></div><br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank"></a><a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank"></a><a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank"></a><a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank"></a><a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Riccardo Tacconi<br>Web developer at Wolseley UK <br><br><a href="http://www.linkedin.com/in/riccardotacconi" target="_blank"></a><a href="http://www.linkedin.com/in/riccardotacconi" target="_blank">http://www.linkedin.com/in/riccardotacconi</a><br>
<a href="http://riccardotacconi.blogspot.com/" target="_blank"></a><a href="http://riccardotacconi.blogspot.com/" target="_blank">http://riccardotacconi.blogspot.com/</a><br>
<a href="http://twitter.com/rtacconi" target="_blank"></a><a href="http://twitter.com/rtacconi" target="_blank">http://twitter.com/rtacconi</a><br>Linux user: #400461<br>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Chat mailing list</span><br><span><a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a></span><br>
<span><a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a></span><br></div></blockquote></div></div></div><br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Riccardo Tacconi<br>Web developer at Wolseley UK <br><br><a href="http://www.linkedin.com/in/riccardotacconi" target="_blank">http://www.linkedin.com/in/riccardotacconi</a><br>
<a href="http://riccardotacconi.blogspot.com/" target="_blank">http://riccardotacconi.blogspot.com/</a><br>
<a href="http://twitter.com/rtacconi" target="_blank">http://twitter.com/rtacconi</a><br>Linux user: #400461<br>
</div></div><br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br>