File: factory_bot.rb

package info (click to toggle)
ruby-factory-bot-rails 6.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 316 kB
  • sloc: ruby: 635; makefile: 6; sh: 4
file content (28 lines) | stat: -rw-r--r-- 577 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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