rails-factory-builder

Generate FactoryBot factories for Rails models from schema and validations.

Updated Dec 8, 2022
One-click install
npx skills add https://github.com/lekemula/dotfiles --skill rails-factory-builder
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-factory-builder
Source: https://github.com/lekemula/dotfiles/tree/main/claude/skills/rails-factory-builder
Command: npx skills add https://github.com/lekemula/dotfiles --skill rails-factory-builder

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates the creation of FactoryBot factories, a common and often repetitive task in Ruby on Rails development, by generating them from model definitions or database schemas.

Core Features & Use Cases

  • Automated Factory Generation: Creates FactoryBot factories based on model attributes, validations, and database constraints.
  • Convention Adherence: Follows standard Rails conventions for factory placement and structure.
  • Use Case: When adding a new model to a Rails application, use this Skill to quickly generate a corresponding FactoryBot factory, ensuring test data can be easily created.

Quick Start

Use the rails-factory-builder skill to generate a FactoryBot factory for the User model.

Frequently Asked Questions about rails-factory-builder

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate FactoryBot factories for Rails models automatically?

To generate FactoryBot factories automatically, this Skill analyzes your Rails model schema and validations to produce factory files with minimal required attributes. It skips auto-managed columns like IDs and timestamps, placing outputs in conventional spec/factories/ or test/factories/ directories.

How does FactoryBot factory generation handle model associations and traits?

Factory generation handles associations and traits by adhering to your project-specific conventions. It reads database constraints and validations to build appropriate associations and traits while utilizing Faker to populate realistic test data for your Rails models.

Can I use Faker with generated FactoryBot factories in Ruby on Rails?

Yes, you can use Faker with generated FactoryBot factories. The generation process integrates Faker to provide realistic, dynamic test data where appropriate, ensuring your factories produce valid and varied records for your Ruby on Rails test suite.

What is the best way to create FactoryBot factories without writing repetitive code?

The best way to create factories without repetitive code is to automate generation from your database schema. This Skill builds factories based on model attributes and validations, avoiding manual boilerplate while skipping auto-managed columns like timestamps.

Does automated factory generation skip auto-managed database columns in Rails?

Yes, automated factory generation skips auto-managed database columns in Rails. It ensures that columns like IDs and timestamps are excluded from the generated FactoryBot factories, focusing only on the necessary data attributes required by your model validations.