Sha256: 944bba79b9865f4ad7d63ec13f9b7b1ad16236a5093247b427fd8c5f46facbea

Contents?: true

Size: 577 Bytes

Versions: 7

Compression:

Stored size: 577 Bytes

Contents

require "rails/generators/named_base"

module FactoryBot
  module Generators
    class Base < Rails::Generators::NamedBase # :nodoc:
      def self.source_root
        path = File.join(
          File.dirname(__FILE__),
          "factory_bot",
          generator_name,
          "templates"
        )

        File.expand_path(path)
      end

      def factory_name
        class_name.gsub("::", "").underscore
      end

      def explicit_class_option
        return if class_name.underscore == factory_name

        ", class: '#{class_name}'"
      end
    end
  end
end

Version data entries

7 entries across 6 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/factory_bot_rails-6.4.4/lib/generators/factory_bot.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/factory_bot_rails-6.4.4/lib/generators/factory_bot.rb
factory_bot_rails-6.4.4 lib/generators/factory_bot.rb
factory_bot_rails-6.4.3 lib/generators/factory_bot.rb
factory_bot_rails-6.4.2 lib/generators/factory_bot.rb
factory_bot_rails-6.4.0 lib/generators/factory_bot.rb
factory_bot_rails-6.3.0 lib/generators/factory_bot.rb