Skip to content

Getting Started

Ngan Pham edited this page Feb 24, 2026 · 1 revision

Getting Started

1. Install

Add FixtureKit in your test group:

group :test do
  gem "fixture_kit"
end

2. Configure Your Test Framework

RSpec:

# spec/rails_helper.rb
require "fixture_kit/rspec"

RSpec.configure do |config|
  config.use_transactional_fixtures = true
end

Minitest:

# test/test_helper.rb
require "fixture_kit/minitest"

class ActiveSupport::TestCase
  self.use_transactional_tests = true
end

3. Define Your First Fixture

# spec/fixture_kit/project_management.rb
FixtureKit.define do
  owner = User.create!(name: "Alice", email: "alice@example.com")
  project = Project.create!(name: "Roadmap", owner: owner)

  expose(owner: owner, project: project)
end

If you use Minitest conventions, place fixture files under test/fixture_kit.

4. Use the Fixture in a Test

RSpec example:

RSpec.describe Project do
  fixture "project_management"

  it "belongs to the exposed owner" do
    expect(fixture.project.owner).to eq(fixture.owner)
  end
end

fixture returns a Repository. Exposed entries become methods (fixture.owner, fixture.project).

Next

Clone this wiki locally