Questions tagged [faker]

An extension or library used in certain programming languages or frameworks (namely Ruby or Yii2) for generating fake data for debug purposes and testing.

In Ruby, Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc.

In Yii2, Faker can generate random strings (like name, address, phone number or anything), random numbers, keys or harshes as well as long sentences of fake text. It can be accessed in OOP style.

A PHP library is available for Faker that is used in some frameworks such as Laravel.

703 questions
0
votes
2 answers

How can I maintain foreign keys when seeding database with Faker?

Below is my model factory. $factory->define(App\Business::class, function (Faker\Generator $faker){ return [ 'name' => $faker->bs, 'slug' => $faker->slug, 'address' => $faker->streetAddress, 'phone_no' => $faker->phoneNumber, 'mobile_no' =>…
Raihan Mahmud
  • 78
  • 1
  • 11
0
votes
1 answer

How faker generate a yaml list that browser understand?

I've sent request use POST method response = user.post(url , data) here is the YAML data: description: "{{text}}" tags: - "{{tags}}" private: true background: "{{background}}" name: "{{name}}" i'm using Faker for the lazy data and here is the…
khue bui
  • 1,366
  • 3
  • 22
  • 30
0
votes
2 answers

Laravel 5.2 seed specific data array

I am trying to seed my database with some specific content to get my application started. I am aware of Faker and how to use it (which I do for my Users). Now I want to fill a table with (alot) of records that are not randomly generated, so not…
nclsvh
  • 2,628
  • 5
  • 30
  • 52
0
votes
1 answer

Generating test data with Faker

I am working on a script to generate test data using faker and JSON-Schema-Faker packages. Looking for examples with "schema inheritance" and optional fields. For example, I have a 'user' object with mandatory fields: '_id', 'firstName', 'lastName',…
Moshe Shmukler
  • 1,270
  • 2
  • 21
  • 43
0
votes
0 answers

WATIR: faker gem not working

I have module module FakeText require 'faker' require 'xkcd' module FakeText def generate_title "Auto Title: #{Faker::Commerce.department} #{get_current_time}" end I am using it as: require_relative…
paul
  • 4,333
  • 16
  • 71
  • 144
0
votes
1 answer

Parse error in Faker for Laravel 5.0

I use "fzaninotto/faker": "^1.5"
Jack Russel
  • 321
  • 2
  • 7
0
votes
0 answers

Set MySQL Timestamp field using Faker

I can't seem to get a timestamp in a format that my database seeder will accept. I am running this command in php artisan tinker: $faker->dateTimeThisYear($max = '+1 year')->format('Y-m-d H:i:s') Which produces: "2015-03-17 01:26:44" As far as I…
Marcel Gruber
  • 6,668
  • 6
  • 34
  • 60
0
votes
1 answer

Set Rules in Seeds.rb in Rails

all. I'm currently adding to my seeds.rb file in Rails using the faker gem. I'm wondering: how do you get the fake data to follow "the rules" I want? I'm building a basketball statistics application. I want stat in seeds to create 300 sets of…
Jay
  • 25
  • 1
  • 3
0
votes
1 answer

Faker Gem creating fake picture not working

Why am i not able to create a fake picture? Picture is polymorphic to several things including the model proposal: This is my faker data: for n in 1..10 do picture = Picture.create!( picture: Faker::Avatar.image("my-own-slug"), …
james
  • 519
  • 3
  • 10
  • 19
0
votes
1 answer

how can I run test files on Windows using rake?

UPDATE: when I run rake test from root, I get: C:\workspace\faker>rake test DL is deprecated, please use Fiddle C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe -w -I"lib;test;." -I"C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib"…
user2993456
0
votes
1 answer

Rails - FactoryGirl - test models [validation]

I would like to test my models but all informations that I could find seems to be outdated. My goal is to test each individual validation. My model: class Author < ActiveRecord::Base has_and_belongs_to_many :books before_save :capitalize_names …
mike927
  • 682
  • 1
  • 8
  • 25
0
votes
1 answer

Faker gem - Where is the data being fetched

I'm trying to understand how the Faker rails gem works, so hopefully I can contribute to it. The project is found here: https://github.com/stympy/faker Under ~/lib/faker/name.rb there will be code like this: def first_name; fetch('name.first_name');…
userFriendly
  • 474
  • 3
  • 14
0
votes
1 answer

Seed data with valid city and state

I'm using Faker to generate seed data. I'm also using the Geocoder gem and API to validate addresses. The problem I'm facing is that the city is fake so most of my seed data isn't able to geocode. Is there a good way to get real city and state…
user2954587
  • 4,661
  • 6
  • 43
  • 101
0
votes
3 answers

Using Faker in Laravel 5.0 returns 'Class User not found'

I am trying to put test data in a database for a Laravel project. I have followed the instructions on Laracasts, and a couple of sites. When I try to run my Seeder class, I get "Class 'User' not found" Here is my class: use…
Roger Creasy
  • 1,419
  • 2
  • 19
  • 35
0
votes
1 answer

Using Model Attributes inside another Model's Factory - Rails

I have a factory called Message, which HABTM Users. I want to mock sender_id inside the Message Factory. If I do: sender_id { FactoryGirl.build(:user}.id } I get: FactoryGirl:DuplicateDefinitionError How can I refer to another factory's data…
dimitry_n
  • 2,939
  • 1
  • 30
  • 53