File: rspec_generator.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 (30 lines) | stat: -rw-r--r-- 646 bytes parent folder | download | duplicates (3)
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
29
30
module FactoryBotRails
  module Generators
    class RSpecGenerator
      def initialize(generators)
        @generators = generators
      end

      def run
        @generators.fixture_replacement(
          fixture_replacement_setting,
          dir: factory_bot_directory
        )
      end

      private

      def fixture_replacement_setting
        @generators.options[:rails][:fixture_replacement] || :factory_bot
      end

      def factory_bot_directory
        factory_bot_options.fetch(:dir, "spec/factories")
      end

      def factory_bot_options
        @generators.options.fetch(:factory_bot, {})
      end
    end
  end
end