Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rename FactoryBot files from singular to plural.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activesupport'
end
require 'active_support/inflector'
require 'pathname'
Pathname.glob('spec/factories/**/*.rb').each do |pathname|
basename = pathname.basename('.rb').to_s.pluralize
pathname.rename("#{pathname.dirname}/#{basename}.rb")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment