mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
parent
854ea5bdf7
commit
18a512576f
4 changed files with 8 additions and 7 deletions
|
@ -13,8 +13,8 @@ module FactoryGirl
|
|||
end
|
||||
|
||||
def self.build_from_definition(definition)
|
||||
build_to_create &definition.to_create
|
||||
build_constructor &definition.constructor
|
||||
build_to_create(&definition.to_create)
|
||||
build_constructor(&definition.constructor)
|
||||
add_callbacks definition.callbacks
|
||||
end
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@ module FactoryGirl
|
|||
end
|
||||
|
||||
def initialize(build_strategy, overrides = {})
|
||||
@build_strategy = build_strategy
|
||||
@overrides = overrides
|
||||
@build_strategy = build_strategy
|
||||
@overrides = overrides
|
||||
@cached_attributes = overrides
|
||||
@instance = nil
|
||||
|
||||
@overrides.each do |name, value|
|
||||
singleton_class.define_attribute(name) { value }
|
||||
|
|
|
@ -78,7 +78,7 @@ describe FactoryGirl::DefinitionProxy, "#method_missing" do
|
|||
|
||||
it "declares a dynamic attribute" do
|
||||
attribute_value = -> { "dynamic attribute" }
|
||||
proxy.attribute_name &attribute_value
|
||||
proxy.attribute_name(&attribute_value)
|
||||
subject.should have_dynamic_declaration(:attribute_name).with_value(attribute_value)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,8 +13,8 @@ module DefineConstantMacros
|
|||
def define_model(name, columns = {}, &block)
|
||||
model = define_class(name, ActiveRecord::Base, &block)
|
||||
create_table(model.table_name) do |table|
|
||||
columns.each do |name, type|
|
||||
table.column name, type
|
||||
columns.each do |column_name, type|
|
||||
table.column column_name, type
|
||||
end
|
||||
end
|
||||
model
|
||||
|
|
Loading…
Add table
Reference in a new issue