I use a decorator module that get's included in a model instance (through the "extends" method). So for example :
module Decorator
  def foo
  end
end
class Model < ActiveRecord::Base
end
class ModelsController < ApplicationController
  def bar
    @model = Model.find(params[:id])
    @model.extend(Decorator)
    @model.foo
  end
end
Then I would like in the tests to do the following (using Mocha) :
test "bar" do
  Model.any_instance.expects(:foo).returns("bar")
  get :bar
end 
Is this possible somehow, or do you have in mind any other way to get this functionality???
 
                        
It works (confirmed in a test application with render :text)
I usually include decorators (instead of extending them at runtime) and I avoid any_instance since it's considered bad practice (I mock find instead).