testing-faker

A Rails testing rule for using Faker, a library that creates realistic-looking sample data, when test values do not need to be fixed.

In plain words
What is it for?
Use it when creating test names, emails, addresses, dates, business values, content, or identifiers, while keeping assertion-specific values fixed.
Why use it?
It reduces repetitive hand-written sample data while keeping tests varied and representative.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/wintermeyer/cursor-rails-rules/testing-faker
Clone the repo
git clone --depth 1 https://github.com/wintermeyer/cursor-rails-rules

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,298 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01298
Opus 5 $0.00000 $0.00649
Sonnet 5 $0.00000 $0.00260
Haiku 4.5 $0.00000 $0.00130

Measured 2d ago against content hash d2f876d2d6d5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-faker scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/testing-faker.mdc · 201 lines

How it starts

The opening of the file, as written. The whole thing — 201 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Faker Standards

Use the faker gem to generate test data when it makes sense. Install the faker gem if it is not already included in the Gemfile.

Usage Guidelines

  1. When to Use Faker
  • All personal information (names, emails, addresses)
  • All business data (products, prices, descriptions)
  • All dates and times (except fixed dates)
  • All content (articles, comments, posts)
  • All identifiers (except fixed IDs)
  1. When NOT to Use Faker
  • Primary keys or foreign keys
  • Fixed enumeration values
  • Status flags or boolean fields
  • Test-specific values needed for assertions

Common Patterns

  1. Personal Information
FactoryBot.define do
  factory :user do
    first_name { Faker::Name.first_name }
    last_name { Faker::Name.last_name }
    email { Faker::Internet.email(name: "#{first_name} #{last_name}") }
    phone { Faker::PhoneNumber.phone_number }
    date_of_birth { Faker::Date.birthday(min_age: 18, max_age: 65) }
    bio { Faker::Lorem.paragraph(sentence_count: 2) }
  end
end
  1. Business Data
FactoryBot.define do
  factory :product do
    name { Faker::Commerce.product_name }
    description { Faker::Lorem.paragraph }
    price { Faker::Commerce.price(range: 10.0..1000.0) }
    sku { Faker::Barcode.ean }
    category { Faker::Commerce.department }
    brand { Faker::Company.name }
  end

  factory :company do
    name { Faker::Company.name }
    catch_phrase { Faker::Company.catch_phrase }
    industry { Faker::Company.industry }
    website { Faker::Internet.url }
    founded_at { Faker::Date.between(from: 20.years.ago, to: 1.year.ago) }
  end
end
  1. Content Generation
FactoryBot.define do
  factory :article do
    title { Faker::Lorem.sentence(word_count: 4) }
    content { Faker::Lorem.paragraphs(number: 3).join("\n\n") }
    excerpt { Faker::Lorem.paragraph }
    author_name { Faker::Name.name }
    published_at { Faker::Time.between(from: 1.year.ago, to: Time.current) }

    trait :with_tags do
      after(:build) do |article|
        article.tags = [
          Faker::Lorem.word,
          Faker::Lorem.word,
          Faker::Lorem.word
        ].uniq
      end
    end
  end

  factory :comment do
    content { Faker::Lorem.paragraph }
    author_name { Faker::Internet.username }
    author_email { Faker::Internet.email }
    ip_address { Faker::Internet.ip_v4_address }
  end
end

Read the full file on GitHub · 201 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 201 lines · 0 tokens per session scan A d2f876d2d6d5

Subscribe to this mod's changes

testing-faker is a cursor rule published in the GitHub repository wintermeyer/cursor-rails-rules (37 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,298 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.