Note that there are some explanatory texts on larger screens.

plurals
  1. POFailure/Error: assigns(:posts).should eq([post])
    primarykey
    data
    text
    <p>post_controller_spec.rb</p> <pre><code>require 'spec_helper' describe Blog::PostsController do let!(:posts) { FactoryGirl.create_list(:post, 3) } let!(:post) { posts.first } describe "GET index" do it "renders the :index view" do get :index assigns(:posts).should eq([post]) response.should render_template :index end end describe "GET show" do context "invalid post" do before do get :show, :id =&gt; 99 end it "redirects to the 404 page" do response.should render_template(:file =&gt; "#{Rails.root}/public/404.html") end end context "valid post" do it "show page" do get :show, id: post assigns(:post).should eq(post) response.should render_template :show end end end end </code></pre> <p>This is my index action:</p> <pre><code>def index @posts = Post.all.order_by(created_at: :desc).page(params[:page]) respond_to do |format| format.html end end </code></pre> <p>I'm getting this error:</p> <pre><code>1) Blog::PostsController GET index renders the :index view Failure/Error: assigns(:posts).should eq([post]) expected: [#&lt;Post _id: 517ebb98a616542f41000002, created_at: 2013-04-29 18:27:36 UTC, updated_at: 2013-04-29 18:27:36 UTC, image_filename: nil, impressions_count: nil, tags: ["tag1", "tag2", "tag3", "tag4"], _slugs: ["post-number-1"], title: "Post number 1", content: "[\"Maiores dolor illum distinctio eveniet perspiciatis necessitatibus consequatur. Dicta ratione repellat ullam sit sed inventore voluptatem. Possimus magni cum dolores rerum voluptas quibusdam. Sed rerum atque accusantium amet aut.\", \"Consequatur ab eum voluptatem voluptatem sit et. Natus soluta quam sed quasi vel odio assumenda. Nulla excepturi dicta voluptatem voluptas vel sit.\"]", image: nil, image_cache: nil, remove_image: nil, admin_id: "517ebb98a616542f41000001"&gt;] got: #&lt;Mongoid::Criteria selector: {} options: {:sort=&gt;{"created_at"=&gt;-1}, :limit=&gt;9, :skip=&gt;0} class: Post embedded: false&gt; (compared using ==) Diff: @@ -1,2 +1,6 @@ -[#&lt;Post _id: 517ebb98a616542f41000002, created_at: 2013-04-29 18:27:36 UTC, updated_at: 2013-04-29 18:27:36 UTC, image_filename: nil, impressions_count: nil, tags: ["tag1", "tag2", "tag3", "tag4"], _slugs: ["post-number-1"], title: "Post number 1", content: "[\"Maiores dolor illum distinctio eveniet perspiciatis necessitatibus consequatur. Dicta ratione repellat ullam sit sed inventore voluptatem. Possimus magni cum dolores rerum voluptas quibusdam. Sed rerum atque accusantium amet aut.\", \"Consequatur ab eum voluptatem voluptatem sit et. Natus soluta quam sed quasi vel odio assumenda. Nulla excepturi dicta voluptatem voluptas vel sit.\"]", image: nil, image_cache: nil, remove_image: nil, admin_id: "517ebb98a616542f41000001"&gt;] +#&lt;Mongoid::Criteria + selector: {} + options: {:sort=&gt;{"created_at"=&gt;-1}, :limit=&gt;9, :skip=&gt;0} + class: Post + embedded: false&gt; # ./spec/controllers/blog/posts_controller_spec.rb:8:in `block (3 levels) in &lt;top (required)&gt;' </code></pre> <p><strong>My show action, pass the test. Where have I the error on index action?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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