Use CaseUpdated
RSpec Fixtures with MockHero
spec_helper.rb
require "net/http"
require "json"
RSpec.configure do |config|
config.before(:suite) do
body = {
seed: 1,
tables: [
{ name: "users", count: 20, fields: [
{ name: "id", type: "uuid" },
{ name: "email", type: "email" }
]},
{ name: "orders", count: 80, fields: [
{ name: "id", type: "uuid" },
{ name: "user_id", type: "ref", ref: "users.id" },
{ name: "total", type: "price" }
]}
]
}
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"])
Order.insert_all(data["orders"])
end
end
Get Started
D
Founder of MockHero. Writes about synthetic test data, agent workflows, and database seeding with MockHero.
Start generating test data for free
500 records/day on the free tier. No credit card required.
Get Your API Key