Framework
Ruby Test Data Generation with MockHero
Client Helper
require "net/http"
require "json"
def mockhero(tables, seed: nil)
body = { tables: tables }
body[:seed] = seed if seed
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"]
)
JSON.parse(res.body)
end
data = mockhero([
{ name: "users", count: 50, fields: [
{ name: "id", type: "uuid" },
{ name: "email", type: "email" }
]},
{ name: "posts", count: 200, fields: [
{ name: "id", type: "uuid" },
{ name: "user_id", type: "ref", ref: "users.id" },
{ name: "title", type: "sentence" }
]}
], seed: 42)
Get Started
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