Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'test/unit'
require 'rubygems'
require 'mocha'

class TestFoo < Test::Unit::TestCase

  class FooController
    def bar_action
      operation_with_render
    end
    
    def operation_with_render
      render :text => 'hello'
    end
    
    def render options = {}
      puts options[:text]
    end
  end
  
  def setup
    @controller = FooController.new
  end

  def test_bar
    @controller.expects(:operation_with_render).returns( Proc.new{ @controller.render :text => 'goodbye' } )
    @controller.bar_action
  end
end