1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot_rails.git synced 2022-11-09 11:49:18 -05:00
thoughtbot--factory_bot_rails/lib/generators/factory_bot.rb

29 lines
576 B
Ruby
Raw Normal View History

require "rails/generators/named_base"
module FactoryBot
module Generators
class Base < Rails::Generators::NamedBase #:nodoc:
def self.source_root
2018-09-28 22:34:23 -04:00
path = File.join(
File.dirname(__FILE__),
"factory_bot",
generator_name,
"templates"
2018-09-28 22:34:23 -04:00
)
File.expand_path(path)
end
def factory_name
class_name.gsub("::", "").underscore
end
def explicit_class_option
return if class_name.underscore == factory_name
2018-09-28 22:34:23 -04:00
", class: '#{class_name}'"
end
end
end
end