Class: FactoryBot::Strategy::Stub

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_bot/strategy/stub.rb

Constant Summary collapse

DISABLED_PERSISTENCE_METHODS =
[
  :connection,
  :decrement!,
  :delete,
  :destroy!,
  :destroy,
  :increment!,
  :reload,
  :save!,
  :save,
  :toggle!,
  :touch,
  :update!,
  :update,
  :update_attribute,
  :update_attributes!,
  :update_attributes,
  :update_column,
  :update_columns
].freeze
@@next_id =
1000

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_id=(id) ⇒ Object


27
28
29
# File 'lib/factory_bot/strategy/stub.rb', line 27

def self.next_id=(id)
  @@next_id = id
end

Instance Method Details

#association(runner) ⇒ Object


31
32
33
# File 'lib/factory_bot/strategy/stub.rb', line 31

def association(runner)
  runner.run(:build_stubbed)
end

#result(evaluation) ⇒ Object


35
36
37
38
39
40
41
42
# File 'lib/factory_bot/strategy/stub.rb', line 35

def result(evaluation)
  evaluation.object.tap do |instance|
    stub_database_interaction_on_result(instance)
    set_timestamps(instance)
    clear_changes_information(instance)
    evaluation.notify(:after_stub, instance)
  end
end

#to_symObject


44
45
46
# File 'lib/factory_bot/strategy/stub.rb', line 44

def to_sym
  :stub
end