CtrlK
BlogDocsLog inGet started
Tessl Logo

igmarin/rails-agent-skills

Curated library of 39 AI agent skills for Ruby on Rails development. Organized by category: planning, testing, code-quality, ddd, engines, infrastructure, api, patterns, context, orchestration, and workflows. Includes 5 callable workflow skills (rails-tdd-loop, rails-review-flow, rails-setup-flow, rails-quality-flow, rails-engines-flow) for complete development cycles. Covers code review, architecture, security, testing (RSpec), engines, service objects, DDD patterns, and TDD automation.

95

1.20x
Quality

98%

Does it follow best practices?

Impact

95%

1.20x

Average score across 35 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

TESTING.mdskills/api/rails-graphql-best-practices/

GraphQL Testing Reference

Spec Template

# spec/graphql/mutations/create_order_spec.rb
RSpec.describe "Mutations::CreateOrder" do
  let(:user)    { create(:user) }
  let(:product) { create(:product, stock: 5) }
  let(:query) do
    <<~GQL
      mutation CreateOrder($productId: ID!, $quantity: Int!) {
        createOrder(input: { productId: $productId, quantity: $quantity }) {
          order { id }
          errors
        }
      }
    GQL
  end

  subject(:result) do
    AppSchema.execute(query, variables: { productId: product.id, quantity: 1 },
                              context: { current_user: user })
  end

  it "creates an order" do
    expect(result.dig("data", "createOrder", "errors")).to be_empty
    expect(result.dig("data", "createOrder", "order", "id")).to be_present
  end

  context "when unauthenticated" do
    subject(:result) { AppSchema.execute(query, variables: { productId: product.id, quantity: 1 }) }

    it "returns an authorization error" do
      expect(result["errors"]).not_to be_empty
    end
  end
end

Call AppSchema.execute directly in GraphQL specs. Do not route these checks through controller/request dispatch when the behavior under test is schema, resolver, authorization, or mutation response shape.

What to Always Test

  • Happy path — successful query/mutation
  • Authorization — unauthenticated (no context user), unauthorized (wrong role)
  • Validation errors — mutation returns errors array, not exception
  • N+1 — query count matchers for resolvers with associations
  • Depth/complexity limits — exceeding limits returns an error, not data

Spec Paths

Test typeSuggested path
Query resolversspec/graphql/queries/..._spec.rb
Mutationsspec/graphql/mutations/..._spec.rb
Typesspec/graphql/types/..._spec.rb (only if type has custom logic)
Resolver objectsspec/graphql/resolvers/..._spec.rb

skills

api

rails-graphql-best-practices

README.md

tile.json