2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Testで使える】Faker の主要メソッド12選

Last updated at Posted at 2023-11-12

Faker Gemの主要メソッド15選

Faker Gemはテストデータの作成に利用される便利なツールで、以下の15の主要なメソッドがあります。

Fakerの便利なメソッド一覧

  1. 郵便番号: Faker::Number.leading_zero_number(digits: 3) + '-' + Faker::Number.leading_zero_number(digits: 4)

    • 例: "025-4893"
  2. 都道府県ID: Faker::Number.between(from: 2, to: 48)

    • 例: 15
  3. 市町村: Faker::Address.city

    • 例: "東京"
  4. 住所: Faker::Address.street_address

    • 例: "南1-3-7"
  5. ビル名: Faker::Company.name

    • 例: "株式会社ABC"
  6. 電話番号: Faker::Number.leading_zero_number(digits: 11)

    • 例: "09012345678"
  7. トークン: Faker::Alphanumeric.alphanumeric(number: 30)

    • 例: "ecfyudjxaniau6toy2bs9el3kpa7bq"
  8. 文章: Faker::Lorem.sentence

    • 例: "Sit voluptatem aut enim quos."
  9. 価格: Faker::Number.between(from: 300, to: 9_999_999)

    • 例: 7354928
  10. 日付: Faker::Date.birthday

    • 例: 1990-08-15
  11. パスワード: '1a' + Faker::Internet.unique.password(min_length: 6)

    • 例: "1aBcDeFg123"
  12. メールアドレス: Faker::Internet.unique.email

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?