Curated library of AI agent skills for Ruby on Rails development. Covers code review, architecture, security, testing (RSpec), engines, service objects, DDD patterns, and workflow automation.
98
99%
Does it follow best practices?
Impact
98%
1.38xAverage score across 26 eval scenarios
Passed
No known issues
A marketing platform sends bulk email campaigns to user segments. The Campaigns::DeliveryService service object coordinates the process: it retrieves the campaign and user segment from the database, then calls an external email provider (SendgridClient) to dispatch the emails. A junior developer wrote the initial implementation but left it entirely untested. The service is going into production next week and the team needs full spec coverage before the release.
You have been asked to write RSpec specs for this service along with the FactoryBot factory definitions needed to support the tests. The service needs to be thoroughly tested, including the success path, failures from the email provider, and record-not-found scenarios for a missing campaign or segment.
The following file is provided. Extract it before beginning.
=============== FILE: app/services/campaigns/delivery_service.rb ===============
module Campaigns class DeliveryService def self.call(campaign_id:, segment_id:) new(campaign_id: campaign_id, segment_id: segment_id).call end
def initialize(campaign_id:, segment_id:)
@campaign_id = campaign_id
@segment_id = segment_id
end
def call
campaign = Campaign.find(@campaign_id)
segment = UserSegment.find(@segment_id)
recipients = segment.users
result = SendgridClient.deliver(
to: recipients.map(&:email),
subject: campaign.subject,
body: campaign.body
)
if result[:success]
{ success: true, response: { delivered_count: recipients.count } }
else
{ success: false, response: { error: result[:error] } }
end
rescue ActiveRecord::RecordNotFound => e
{ success: false, response: { error: e.message } }
endend end
Produce:
spec/services/campaigns/delivery_service_spec.rb — comprehensive RSpec spec for the servicespec/factories/campaigns.rb — FactoryBot factory definitions needed to support the specsThe spec must cover: successful email delivery, a delivery failure returned by the email provider, and a not-found error for a missing campaign or segment.
For the FactoryBot factories, define only what the tests actually need — the factories should be lean and focused on the attributes the specs depend on.
api-rest-collection
create-prd
ddd-boundaries-review
ddd-rails-modeling
ddd-ubiquitous-language
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20
scenario-21
scenario-22
scenario-23
scenario-24
scenario-25
scenario-26
generate-tasks
mcp_server
rails-architecture-review
rails-background-jobs
rails-bug-triage
rails-code-conventions
rails-code-review
rails-engine-compatibility
rails-engine-docs
rails-engine-extraction
rails-engine-installers
rails-engine-release
rails-engine-reviewer
rails-engine-testing
rails-graphql-best-practices
rails-migration-safety
rails-review-response
rails-security-review
rails-skills-orchestrator
rails-stack-conventions
rails-tdd-slices
refactor-safely
rspec-best-practices
rspec-service-testing
ruby-service-objects
strategy-factory-null-calculator
ticket-planning
yard-documentation