File: factory_bot_strategy.rb

package info (click to toggle)
ruby-test-prof 0.12.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 508 kB
  • sloc: ruby: 4,075; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 553 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

module TestProf
  # FactoryBot 5.0 uses strategy classes for associations,
  # older versions and top-level invocations use Symbols.
  #
  # This Refinement should be used FactoryRunner patches to check
  # that strategy is :create.
  module FactoryBotStrategy
    refine Symbol do
      def create?
        self == :create
      end
    end

    if defined?(::FactoryBot::Strategy::Create)
      refine Class do
        def create?
          self <= ::FactoryBot::Strategy::Create
        end
      end
    end
  end
end