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
1 answer

RoR Faker Information Not Displaying

I installed 'faker' gem but when I use it (Faker::Book.name) it doesn't display a random name, but only a string "Faker::Book" lib > tasks > data_populate require 'colorize' namespace :data_populate do namespace :populate do desc "Populate all…
0
votes
1 answer

Laravel Faker lowercase

This sounds very trivial but I can't seem to figure it out... I normally have my db columns like so; Table Name: City **id** - 1 **name** - Cityx **value** - cityx as you can see value is exactly like name but in lowercase. Now I'm trying to use…
moh_abk
  • 2,064
  • 7
  • 36
  • 65
0
votes
1 answer

rake db:seed not working as expected

I am trying to seed a database with initial users. The first two are testing accounts and populate fine: User.create! :name => "Name", :surname => "Lastname", :admin => 't', :email => "admin@testing.co", :encrypted_password =>…
Matteo
  • 1,136
  • 1
  • 16
  • 36
0
votes
1 answer

Why does my FactoryGirl create method get stuck in an infinite loop?

I am using Rails 5.0.0.rc1, ruby 2.3.0p0, factory_girl (4.7.0), factory_girl_rails (4.7.0), faker (1.6.3). At my console, I do & get the following: [1] pry(main)> q1 = FactoryGirl.create(:question) (0.2ms) BEGIN SQL (1.1ms) INSERT INTO…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
0
votes
1 answer

Faker gem with seeds.rb

I am looking to refactor my seeds.rb file. As such, I am relying heavily on the gem faker to populate data. First I'm generating users, like this: # --== Generate Sample Users user_list = [ [ "Name", "Lastname", "Password", 't',…
Matteo
  • 1,136
  • 1
  • 16
  • 36
0
votes
1 answer

Fzaninotto Faker PHP Fatal Error

I keep getting this error when I am trying to test Faker PHP from github on my server: Fatal error: Class 'Faker\Provider\en_US\Address' not found in /home/andrew/public_html/JeffWork/src/Faker/Provider/en_US/Address.php on line 6 Link:…
user6052472
0
votes
1 answer

Laravel 5/Faker - Factory data changes

Been using Faker in combination with sqLite in-memory database for testing in Laravel lately and I have this strange issue where my model has a factory and everything except the first variable (which happens to also be the primary key of the table)…
Kevin Wareman
  • 146
  • 1
  • 7
0
votes
2 answers

How to use Faker in my Rails controller to make a random set of data?

def create climates = ["beachy", "very cold", "dry", "tundra", "rain forest", "north pole"] destination = Destination.create {{name: Faker::Name.last_name + " Island", climate: climates.sample}} redirect_to destinations_path end I want to…
Brendan E
  • 11
  • 2
0
votes
1 answer

FactoryGirl - Faker image for CarrierWave uploader

How can I use Faker's avatar generation with a FactoryGirl Factory ? Faker::Avatar.image returns a URL with an image, can I somehow try to download it during a FactoryGirl create action, so I can use it as a Carrierwave image (and fallback to no…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
0
votes
0 answers

Laravel, Behat, Faker and GuzzleHttp - DB Rollback before I can get the data

I'm try to create a fake data for testing, and have the following code on the Behat Context $modelFake = factory(User::class)->create(); $client = new GuzzleHttp\Client(); $res = $client->request('GET', url($this->apiURL . '/user/' .…
AgeValed
  • 443
  • 5
  • 18
0
votes
2 answers

Invalid record in seeds.rb

I have a problem with finding the problem with my create data method in seeds.rb. I use faker gem to generate data. My code: NAZWY_DNI = ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela'] 60.times do …
Prezes Łukasz
  • 938
  • 1
  • 9
  • 30
0
votes
2 answers

Using Faker directly in an .erb file

For a bit of quick-and-dirty hacking, I would like to get some text into a page. This doesn't seem to work... home.html.erb ...

Heading

<% Faker::Lorem.paragraph(sentence_count = 3) %>
... I have faker in my Gemfile. This just…
0
votes
1 answer

Generating test data that spans days

I would like to have ActiveRecord objects to run tests against that span several days. For example, I want x number of Posts over the last x days so that I can calculate the average rating for posts posted yesterday. This way I know it didn't…
Jared
  • 65
  • 1
  • 4
0
votes
1 answer

faker and factory_girl troubles

Good day! I'm trying to create random values when creating model in my tests. Using factory_girl and faker gems as of my gemfile.lock factory_girl_rails (4.5.0) factory_girl (~> 4.5.0) faker (1.6.1) I define factory as follows…
Elmor
  • 4,775
  • 6
  • 38
  • 70
0
votes
1 answer

Faker for Laravel Seeder

I have a table users in a one-many relationship with a table called videos. I want to seed the two table without loosing data integrity. This is what I did below: $factory->define(App\User::class, function (Faker\Generator $faker) { return [ …
George
  • 3,757
  • 9
  • 51
  • 86