document.write('<link rel="stylesheet" href="http://flowcoder.com/stylesheets/pygment_trac.css" />');
document.write('<link rel="stylesheet" href="http://flowcoder.com/stylesheets/embed.css" />');
document.write('<div class="flowcoder_post flowcoder_clearfix">');
document.write('<div class="flowcoder_posttitle"><a href=\"http://flowcoder.com/32\">stubbing a before_filter that calls out to an api<\/a></div>');
document.write('<div class="flowcoder_postbody flowcoder_syntax"><div class=\"highlight\"><pre><span class=\"c1\"># i had a problem with a before filter that used information from another api.<\/span>\n<span class=\"c1\">#  The api was called all the time in an around filter and i&#39;d use the information to then verify.<\/span>\n<span class=\"c1\"># Well now when i need to stub out a before filter in a functional test i use this code snippet:<\/span>\n<span class=\"nb\">test<\/span> <span class=\"s2\">&quot;User should create user&quot;<\/span>\n  <span class=\"vi\">@controller<\/span><span class=\"o\">.<\/span><span class=\"n\">stubs<\/span><span class=\"p\">(<\/span><span class=\"ss\">:active_user?<\/span><span class=\"p\">)<\/span><span class=\"o\">.<\/span><span class=\"n\">returns<\/span><span class=\"p\">(<\/span><span class=\"kp\">true<\/span><span class=\"p\">)<\/span>\n  <span class=\"n\">get<\/span> <span class=\"ss\">:edit<\/span><span class=\"p\">,<\/span> <span class=\"ss\">:id<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"n\">users<\/span><span class=\"p\">(<\/span><span class=\"ss\">:one<\/span><span class=\"p\">)<\/span><span class=\"o\">.<\/span><span class=\"n\">to_param<\/span>\n  <span class=\"n\">assert_response<\/span> <span class=\"ss\">:success<\/span>\n<span class=\"k\">end<\/span>\n<\/pre><\/div>\n</div>');
document.write('<div class="flowcoder_bottombar flowcoder_clearfix">');
document.write('<div class="flowcoder_postedby">Posted by <a href=\"http://flowcoder.com/pjammer\">pjammer<\/a> on <a href=\"http://flowcoder.com/\">Flowcoder<\/a></div>');
document.write('<div class="flowcoder_viewraw"><a href=\"http://flowcoder.com/32.txt\">view raw<\/a></div>');
document.write('</div></div>');
