class Pickle::Adapter::FactoryBot
factory-girl adapter
Public Class Methods
factories()
click to toggle source
# File lib/pickle/adapter.rb, line 102 def self.factories if defined? ::FactoryBot factories = [] ::FactoryBot.factories.each do |factory| factory.names.each do |name| factories << new(factory, name) end end factories else (::Factory.factories.values rescue []).map {|factory| new(factory)} end end
new(factory, factory_name)
click to toggle source
# File lib/pickle/adapter.rb, line 116 def initialize(factory, factory_name) if defined? ::FactoryBot @klass, @name = factory.build_class, factory_name.to_s else @klass, @name = factory.build_class, factory.factory_name.to_s end end
Public Instance Methods
build(attrs = {})
click to toggle source
# File lib/pickle/adapter.rb, line 132 def build(attrs = {}) if defined? ::FactoryBot ::FactoryBot.build(@name, attrs) else Factory.build(@name, attrs) end end
create(attrs = {})
click to toggle source
# File lib/pickle/adapter.rb, line 124 def create(attrs = {}) if defined? ::FactoryBot ::FactoryBot.create(@name, attrs) else Factory(@name, attrs) end end