Use Case

MockHero vs factory_bot: Rails Seed Data, Compared

TL;DR

factory_bot is excellent for per-test Ruby object factories. MockHero is better when you need a big realistic dataset across many tables, or when your stack isn't Ruby-only.

Scope

  • factory_bot — Ruby library, per-object factories inside RSpec/Minitest.
  • MockHero — HTTP API, whole-dataset generation, usable from Ruby, JS, Python, Go, anything.

Seeding Ruby on Rails

# db/seeds.rb
require "net/http"
require "json"
require "active_record"

body = {
  tables: [
    { name: "users", count: 100, fields: [
      { name: "id", type: "uuid" },
      { name: "email", type: "email" }
    ]},
    { name: "posts", count: 500, fields: [
      { name: "user_id", type: "ref", ref: "users.id" },
      { name: "title", type: "sentence" }
    ]}
  ]
}

res = Net::HTTP.post(
  URI("https://api.mockhero.dev/api/v1/generate"),
  body.to_json,
  "Content-Type" => "application/json",
  "x-api-key" => ENV["MOCKHERO_API_KEY"]
)

data = JSON.parse(res.body)
User.insert_all(data["users"])
Post.insert_all(data["posts"])

When to Combine

Use factory_bot in unit tests for per-test fixtures. Use MockHero in db/seeds.rb and in CI so every developer and every CI run starts with the same realistic 10,000-row dataset.

Realism

MockHero ships 156+ field types (addresses, company names, product SKUs, avatars). factory_bot is neutral about the values — you wire in Faker or write literals. MockHero gives you quality defaults out of the box.

Get Started

Grab a free API key and point your db/seeds.rb at MockHero.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles