Rspec: Как заглушить закрытый метод?

Вот ошибка:

private method `desc' called for #<Array:0x0000010532e280>

спецификация:

describe SubjectsController do  
  before(:each) do
    @subject = mock_model(Subject)
  end

    describe "#0002 - GET #index" do
    before(:each) do        
      subjects = [@subject, mock_model(Subject), mock_model(Subject)]
      Subject.stub!(:all).and_return(subjects)
      Subject.all.stub!(:desc).and_return(subjects)
      get :index
    end

    it { response.should be_success }
    it { response.should render_template("index") }
  end
end

и контроллер:

def index
  @subjects = Subject.all(conditions: {company_id: current_user.company.id}).desc(:created_at)
end

Я не знаю, как решить эту проблему, может кто-нибудь мне помочь? Не могли бы вы также посоветовать, как бы вы протестировали этот метод? Спасибо.

5
задан Pierre-Louis Gottfrois 15 June 2011 в 14:03
поделиться