title: Rails 2.3.x - How to stub a helper method (that gets called from a view) in a functional test (no RSpec)?
body: <p>Please don't tell me "search more" or other stuff cause all solutions for similar question fail.</p>
  
  <p>Simple:
  I have a functional tests. I want to make a simple get and see if proper content gets rendered</p>
  
  <pre>
    test "displays headline if user should see it" do
      get :index  
      assert_match /headline/, response.body
    end
  
    test "doesn't display headline if user shouldn't see it" do
      get :index
      assert_no_match /headline/, response.body
    end
  </pre>
  
  <p>and a simple view</p>
  
  <pre>
    &#60;% if show_headline?(arg) %&#62;
      headline
    &#60;% end %&#62;
  </pre>
  
  <p>and a helper:</p>
  
  <pre>
    module TheHelper
      def show_headline?(arg)
        arg ? hard_code_logic : even_harder_logic
      end
    end
  </pre>
  
  <p>so what I need is to do in test something like:</p>
  
  <pre>
    test "displays headline if user should see it" do
      Something.stubs(:show_headline?).returns(true)
  
      get :index  
      assert_match /headline/, response.body
    end
  
    test "doesn't display headline if user shouldn't see it" do
      Something.stubs(:show_headline?).returns(false)
  
      get :index
      assert_no_match /headline/, response.body
    end
  </pre>
  
  <p>The question is what is Something? I want to stub it cause I have helpers tested in unit/helpers.</p>
  
  <p>After the get helper module gets remixed into the controller class. Please don't give me links to other answers, I read them (but of course I could have read the wrong ones) and they don't work for me. I use Rails 2.3.10 with mocha 0.9.8.</p>
  
  <p>Things that don't work:</p>
  
  <pre>
  TheController.any_instance.stubs(:show_headline?)
  ActionView::Base.any_instance...
  @controller.stubs...
  </pre>
  
  <p>UPDATE:</p>
  
  <p>the only mock that worked was:</p>
  
  <pre>
    &#60;% self.stubs(:show_headline?).returns(true) &#62;%
    &#60;% if show_headline?(arg) %&#62;
      headline
    &#60;% end %&#62;
  </pre>
  
  <p>but of course I will not use that... maybe it is a clue</p>