DEV Community

Cover image for Faker Gem in Ruby 💎💎
Shadiya
Shadiya

Posted on • Updated on

Faker Gem in Ruby 💎💎

Ruby is a dynamic object oriented programming language. It has an elegant yet simple syntax that is easy to use. In ruby, I was introduced to faker. Faker is a tool that allows us to generate as much fake data to test out methods. It is very easy to use and I will be demonstrating that for you right now.

To begin using faker, you need to install the gem, which is simply done by running "gem install faker". You should see this message in the terminal:

Image description

After you do that, you should add "gem "faker"" to your gem file to ensure correct usage, otherwise you may get an error.

Image description

Once thats done you can head over to the seeding file and add require "faker" to the top of the page.

Image description

In the seeding file is where you would start to "fake" your data and we use the faker library to pick out random dummy data. Your going to start implementing the dummy data that you selected from the faker library, which should look like this

Image description

Once thats done you can check sqlite explorer to make sure that you correctly retrieved all the data that you pulled from the faker library. Have fun and "fake it till you make it"!

Top comments (0)