30 Oct '17, 4am

Episode #103 - Sample Data with Factory Bot and Faker #ruby #rails @thoughtbot

Resources Factory Bot Gem - https://github.com/thoughtbot/factory_bot Factory Bot Getting Starting - https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md Faker Gem - https://github.com/stympy/faker Source - https://github.com/driftingruby/103-sample-data-with-factory-bot-and-faker Summary Gemfile group :test do # gem 'factory_bot' gem 'factory_bot_rails' gem 'faker' end rails_helper.rb # require 'support/factory_bot' Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } spec/factories/users.rb FactoryBot.define do factory :user do first_name 'John' last_name 'Doe' email '[email protected] ' active true end factory :random_user, class: User do first_name { Faker::Name.first_name } last_name { Faker::Name.last_name } email { Faker::Internet.safe_email } active true end end user_spec.rb FactoryBot.define do factory :user do first_name 'John' ...

Full article: https://www.driftingruby.com/episodes/sample-data-with-fa...

Tweets

[Screencast] Sample Data with Factory Bot and F...

rubyflow.com 30 Oct '17, 12pm

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...

Announcing rom-factory

rubyflow.com 24 Oct '17, 10am

× The Ruby and Rails community linklog Made a library? Written a blog post? Found a useful tutorial? Share it with the Rub...