Spread the love

Get Ruby Object (that you need to convert to hash) into one variable.

=> user = User.first

#<User id: 1, name: “Test", email: “Test@mail.com", updated_at: "2019-01-23 06:03:20”> 

Below method will convert your Ruby Object into hash.

=> user.as_json

{"id"=>1, "name"=>"Test", "email"=>"Test@mail.com", "updated_at"=>Wed, 23 Jan 2019 06:03:20 UTC +00:00}

Find below link for details about Hash:

https://ruby-doc.org/core-2.2.0/Hash.html

https://www.learningcontainer.com/rspec-for-ruby-on-rails/
Learn About Test cases
Share
Published by
Denail Soovy

Recent Posts

Sample Video Files | MP4 Sample Download

Sample Video files for testing purposes are listed below.That file you can edit and reuse. It's already…

4 months ago

Download Age Calculator in Excel/Xlsx

Age calculator in Excel is a very useful tool for quickly calculating a person's age…

5 months ago

NOC Letter Format for GST Registration Template

Here is the Preview of NOC Format for GST Registration in Word & PDF Download…

5 months ago

Construction & Building Permit NOC Template

Here is the Preview of Construction & Building Permit NOC format in Word & PDF…

5 months ago

Business Licensing No Objection Certificate

Here is the Preview of Business Licensing No Objection Certificate in Word & PDF Download…

5 months ago

NOC Format for Bank Loan

Here is the Preview of NOC Format for Bank Loan in Word & PDF Download…

5 months ago