Note that there are some explanatory texts on larger screens.

plurals
  1. POmongoid, rspec and assigns(:people) issue
    text
    copied!<p>I'm trying to write my first specs for the People Controller Using mongoid (2.0.1), rspec (2.5.0), mongoid-rspec (1.4.2) and fabrication (0.9.5), if necessary.</p> <p>(remark: the Organization model mocked inherits from the Person model)</p> <pre><code>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 </code></pre> <p>I get the <strong>following error message</strong> when I run this spec:</p> <pre><code> 1) PeopleController as logged in user GET 'index' assigns all people as @people Failure/Error: assigns(:people).should eq(mock_person) expected #&lt;Person:0x811b8448 @name="Person_1001"&gt; got #&lt;Mongoid::Criteria selector: {}, options: {}, class: Person, embedded: false&gt; (compared using ==) Diff: @@ -1,2 +1,6 @@ -#&lt;Person:0x811b8448 @name="Person_1001"&gt; +#&lt;Mongoid::Criteria + selector: {}, + options: {}, + class: Person, + embedded: false&gt; # ./spec/controllers/people_controller_spec.rb:24:in `block (4 levels) in &lt;top (required)&gt;' </code></pre> <p>My controller is DRY thanks to inherited_resources (1.2.2) and works in development mode as it should.</p> <pre><code>class PeopleController &lt; InheritedResources::Base actions :index end </code></pre> <p>Any ideas what I'm doing wrong <code>Mongoid::Criteria</code> object?</p> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload