7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/generators/federails/copy_factories/copy_factories_generator.rb', line 7
def copy_factories
dest = Rails.root.join('spec', 'factories')
Dir.entries(SOURCE_DIRECTORY)
.each do |node|
source_path = File.join(SOURCE_DIRECTORY, node)
next unless File.file?(source_path) && node.match?(/\.rb\Z/)
file_path = File.join(dest, "federails_#{node}")
copy_file node, file_path
gsub_file file_path, /(FactoryBot.define do\n\s+factory) :(\w+),/, '\1 :federails_\2,'
end
end
|