mongoid, rspec и assigns (: people) issue

Я пытаюсь написать свои первые спецификации для People Controller Используя mongoid (2.0.1), rspec (2.5.0), mongoid-rspec (1.4.2) и при необходимости, фабрикацию (0.9.5).

(примечание: издевательская модель организации наследуется от модели Person)

describe PeopleController do
  describe "as logged in user" do
    before (:each) do
      @user = Fabricate(:user)
      sign_in @user
    end

    describe "GET 'index'" do
      def mock_person(stubs={})
        @mock_person ||= mock_model(Person, stubs).as_null_object
#        @mock_person ||= Fabricate.build(:organization)       
      end

      it "should be successful" do
        get :index
        response.should be_success
      end

      it "assigns all people as @people" do
        Person.stub(:all) { [mock_person] }
        get :index
        assigns(:people).should eq(mock_person)
      end
    end
  end

Я получаю следующее сообщение об ошибке , когда запускаю эту спецификацию:

    1) PeopleController as logged in user GET 'index' assigns all people as @people
       Failure/Error: assigns(:people).should eq(mock_person)

         expected #<Person:0x811b8448 @name="Person_1001">
              got #<Mongoid::Criteria
           selector: {},
           options:  {},
           class:    Person,
           embedded: false>


         (compared using ==)

         Diff:
         @@ -1,2 +1,6 @@
         -#<Person:0x811b8448 @name="Person_1001">
         +#<Mongoid::Criteria
         +  selector: {},
         +  options:  {},
         +  class:    Person,
         +  embedded: false>
       # ./spec/controllers/people_controller_spec.rb:24:in `block (4 levels) in <top (required)>'

Мой контроллер СУХИЙ благодаря наследуемым_ресурсам (1.2.2) и работает в режиме разработки должным образом.

class PeopleController < InheritedResources::Base
  actions :index
end

Любые идеи что я делаю не так Объект Mongoid :: Criteria ?

Заранее спасибо

6
задан tmaier 10 May 2011 в 12:04
поделиться