Skip to content

Instantly share code, notes, and snippets.

@r7kamura
Last active October 28, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r7kamura/a23efa7d14a2b7c56dfee0959b8ce859 to your computer and use it in GitHub Desktop.
Save r7kamura/a23efa7d14a2b7c56dfee0959b8ce859 to your computer and use it in GitHub Desktop.
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