Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5966877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:51:44+00:00 2026-05-22T19:51:44+00:00

I have a normal Rails project (without Active Record) using CouchDB (couchrest_model) as a

  • 0

I have a normal Rails project (without Active Record) using CouchDB (couchrest_model) as a document database.

I did setup RSpec and a basic scaffold ‘Project’.

When I test the following spec:

  before(:each) do
    @project = Project.create! valid_attributes
  end

  describe "GET index" do
    it "assigns all projects as @projects" do
      get :index
      assigns(:projects).should eq([@project])
    end
  end

I get the following error:

Failure/Error: assigns(:projects).should eq([@project])

       expected [{"name"=>"test", 
                  "updated_at"=>2011-05-28 11:24:04 -0500,
                  "created_at"=>2011-05-28 11:24:04 -0500, 
                  "couchrest-type"=>"Project",
                  "_id"=>"709edbfaafb24fa1eff7d5f3966b2bda",
                  "_rev"=>"1-ae3f6356f8e32f6006337a4f3759bca4"}]
            got [{"name"=>"test",
                  "updated_at"=>2011-05-28 11:24:04 -0500, 
                  "created_at"=>2011-05-28 11:24:04 -0500,
                  "_id"=>"709edbfaafb24fa1eff7d5f3966b2bda",
                  "_rev"=>"1-ae3f6356f8e32f6006337a4f3759bca4",
                  "couchrest-type"=>"Project"}]

It seems that the only difference is the order of the elements in the hash:

  (compared using ==)

   Diff:

   @@ -1,7 +1,7 @@
    [{"name"=>"test",
      "updated_at"=>2011-05-28 11:24:04 -0500,
      "created_at"=>2011-05-28 11:24:04 -0500,
   -  "couchrest-type"=>"Project",
      "_id"=>"709edbfaafb24fa1eff7d5f3966b2bda",
   -  "_rev"=>"1-ae3f6356f8e32f6006337a4f3759bca4"}]
   +  "_rev"=>"1-ae3f6356f8e32f6006337a4f3759bca4",
   +  "couchrest-type"=>"Project"}]

I know ‘rspec’ and ‘rspec-rails’ only work out of the box for Active Record, but it shouldn’t be so different for other ORMs. Am I missing something?

Which is the best way to fix this test?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:51:45+00:00Added an answer on May 22, 2026 at 7:51 pm

    Try:

    assigns(:projects).should == [@project]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Rails application I have an action which creates a XML document using
I am using C# and Windows Forms. I have a normal progress bar working
I have a class defined in a file my Rails project's lib dir that
I have a Rails application with over 2,000 examples in my RSpec tests. Needless
I'm using Ruby on Rails. I have a couple of models which fit the
I have a table in SQL server that has the normal tree structure of
I have the following div layout: Everything is fine when I put normal txt
I have a program that needs to run as a normal user most of
I have a table that's generated by a normal PHP loop. What I want
I have two files with slight differences. A normal diff will show me the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.