All Projects → faker-ruby → Faker

faker-ruby / Faker

Licence: mit
A library for generating fake data such as names, addresses, and phone numbers.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Faker

Jsonplaceholder
A simple online fake REST API server
Stars: ✭ 4,377 (-54.59%)
Mutual labels:  fake
Jaymock
Minimal fake JSON test data generator.
Stars: ✭ 28 (-99.71%)
Mutual labels:  fake
Fake server
FakeServer integrates with ExUnit to make external APIs testing simpler
Stars: ✭ 64 (-99.34%)
Mutual labels:  fake
Fakewechatloc
手把手教你制作一款iOS越狱App
Stars: ✭ 463 (-95.2%)
Mutual labels:  fake
Clj Fakes
An isolation framework for Clojure/ClojureScript.
Stars: ✭ 26 (-99.73%)
Mutual labels:  fake
Dashboard Server
A JSON file RESTful API with authorization based on json-server
Stars: ✭ 48 (-99.5%)
Mutual labels:  fake
Impost3r
👻Impost3r -- A linux password thief
Stars: ✭ 355 (-96.32%)
Mutual labels:  fake
Fakerator
Random fake data generator with localization for Javascript in Node.js and browser
Stars: ✭ 91 (-99.06%)
Mutual labels:  fake
Faker.js
generate massive amounts of realistic fake data in Node.js and the browser
Stars: ✭ 34,329 (+256.18%)
Mutual labels:  fake
Esp8266 wifi captive portal 2.0
🔑 WiFi captive portal for ESP8266 (Fake sign in)
Stars: ✭ 59 (-99.39%)
Mutual labels:  fake
Genact
🌀 A nonsense activity generator
Stars: ✭ 5,109 (-46.99%)
Mutual labels:  fake
Strictly fake
Stub that automatically verifies that stubbed methods exist and the signatures match the original.
Stars: ✭ 18 (-99.81%)
Mutual labels:  fake
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-99.49%)
Mutual labels:  fake
Bogus
📇 A simple and sane fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Stars: ✭ 5,083 (-47.26%)
Mutual labels:  fake
Wp Cli Fixtures
Easily generate custom fake data for WordPress
Stars: ✭ 65 (-99.33%)
Mutual labels:  fake
Pidense
🍓📡🍍Monitor illegal wireless network activities. (Fake Access Points), (WiFi Threats: KARMA Attacks, WiFi Pineapple, Similar SSID, OPN Network Density etc.)
Stars: ✭ 358 (-96.29%)
Mutual labels:  fake
Fake Oauth2 Server
An OAuth2 server implementation to be used for testing
Stars: ✭ 34 (-99.65%)
Mutual labels:  fake
Sns
Fake Amazon SNS
Stars: ✭ 94 (-99.02%)
Mutual labels:  fake
Openapi Sampler
🔠 Tool for generation samples based on OpenAPI(fka Swagger) payload/response schema
Stars: ✭ 83 (-99.14%)
Mutual labels:  fake
Evilgrade
Evilgrade is a modular framework that allows the user to take advantage of poor upgrade implementations by injecting fake updates.
Stars: ✭ 1,086 (-88.73%)
Mutual labels:  fake

logotype a happy-07

Faker

Tests Gem Version Inline docs Test Coverage Maintainability SemVer compatibility

This gem is a port of Perl's Data::Faker library that generates fake data.

It comes in very handy for taking screenshots (taking screenshots for my project, Catch the Best was the original impetus for the creation of this gem), having real-looking test data, and having your database populated with more than one or two records while you're doing development.

NOTE

  • While Faker generates data at random, returned values are not guaranteed to be unique by default. You must explicitly specify when you require unique values, see details. Values also can be deterministic if you use the deterministic feature, see details
  • This is the master branch of Faker and may contain changes that are not yet released. Please refer the README of your version for the available methods. List of all versions is available here.

Installing

gem install faker

Note: if you are getting a uninitialized constant Faker::[some_class] error, your version of the gem is behind the one documented here. To make sure that your gem is the one documented here, change the line in your Gemfile to:

gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'master'

Usage

require 'faker'

Faker::Name.name      #=> "Christophe Bartell"

Faker::Internet.email #=> "[email protected]"

CLI

Instructions are available in the faker-bot README.

Ensuring unique values

Prefix your method call with unique. For example:

Faker::Name.unique.name # This will return a unique name every time it is called

If too many unique values are requested from a generator that has a limited number of potential values, a Faker::UniqueGenerator::RetryLimitExceeded exception may be raised. It is possible to clear the record of unique values that have been returned, for example between tests.

Faker::Name.unique.clear # Clears used values for Faker::Name
Faker::UniqueGenerator.clear # Clears used values for all generators

You also can give some already used values to the unique generator if you have collisions with the generated data (i.e: using FactoryBot with random and manually set values).

# Usage:
# Faker::<generator>.unique.exclude(method, arguments, list)

# Add 'azerty' and 'wxcvbn' to the string generator with 6 char length
Faker::Lorem.unique.exclude :string, [number: 6], %w[azerty wxcvbn]

Deterministic Random

Faker supports seeding of its pseudo-random number generator (PRNG) to provide deterministic output of repeated method calls.

Faker::Config.random = Random.new(42)
Faker::Company.bs #=> "seize collaborative mindshare"
Faker::Company.bs #=> "engage strategic platforms"
Faker::Config.random = Random.new(42)
Faker::Company.bs #=> "seize collaborative mindshare"
Faker::Company.bs #=> "engage strategic platforms"

Faker::Config.random = nil # seeds the PRNG using default entropy sources
Faker::Config.random.seed #=> 185180369676275068918401850258677722187
Faker::Company.bs #=> "cultivate viral synergies"

Generators

NOTE: Some of the generators below aren't released yet. If you want to use them, change the line in your gemfile to:

gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'master'

Default

Blockchain

Books

Fantasy

Creature

Games

Japanese Media

Movies

Music

Quotes

Sports

Tv Shows

Customization

Since you may want to make addresses and other types of data look different depending on where in the world you are (US postal codes vs. UK postal codes, for example), Faker uses the I18n gem to store strings (like state names) and formats (US postal codes are NNNNN while UK postal codes are AAN NAA), allowing you to get different formats by switching locales. Just set the locale you want as shown below, and Faker will take care of the rest.

Faker::Config.locale = 'es'
# or
Faker::Config.locale = :es

If your locale doesn't already exist, create it in the lib/locales directory and you can then override or add elements to suit your needs. See more about how to use locales here

en-au-ocker:
  faker:
    name:
      # Existing faker field, new data
      first_name:
        - Charlotte
        - Ava
        - Chloe
        - Emily

      # New faker fields
      ocker_first_name:
        - Bazza
        - Bluey
        - Davo
        - Johno
        - Shano
        - Shazza
      region:
        - South East Queensland
        - Wide Bay Burnett
        - Margaret River
        - Port Pirie
        - Gippsland
        - Elizabeth
        - Barossa

Contributing

See CONTRIBUTING.md.

Contact

Comments and feedback are welcome. Send an email to Benjamin Curtis via the google group.

You can also join our discord channel to discuss anything regarding improvements or feature requests.

License

This code is free to use under the terms of the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].