I am trying to write my first specifications for People Controller Using mangoid (2.0.1), rspec (2.5.0), mongoid-rspec (1.4.2) and manufacturing (0.9.5), if necessary.
(note: the Organization model is derided inherited from the Person model)
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
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
I get the following error when starting this specification:
1) PeopleController as logged in user GET 'index' assigns all people as @people
Failure/Error: assigns(:people).should eq(mock_person)
expected
got
selector: {},
options: {},
class: Person,
embedded: false>
(compared using ==)
Diff:
@@ -1,2 +1,6 @@
-
+
+ selector: {},
+ options: {},
+ class: Person,
+ embedded: false>
Thanks to inherited_resources (1.2.2), my DRY controller works in development mode, as it should be.
class PeopleController < InheritedResources::Base
actions :index
end
Any ideas what I am doing wrong Mongoid::Criteriaobject?
Thanks in advance
source
share