1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00

Clean up more method scoping

This commit is contained in:
Joshua Clayton 2011-10-07 16:06:28 -04:00
parent 39caed08c7
commit 7f42abe6be
2 changed files with 8 additions and 15 deletions

View file

@ -54,10 +54,6 @@ module FactoryGirl
@attribute_list.overridable?
end
def add_child(factory)
@children << factory unless @children.include?(factory)
end
def define_trait(trait)
@defined_traits << trait
end
@ -147,10 +143,6 @@ module FactoryGirl
@to_create_block = block
end
def callbacks
attributes.callbacks
end
def ensure_compiled
compile unless @compiled
end
@ -165,8 +157,16 @@ module FactoryGirl
@class_name || (parent && parent.class_name) || name
end
def add_child(factory)
@children << factory unless @children.include?(factory)
end
private
def callbacks
attributes.callbacks
end
def compile
inherit_factory(parent) if parent

View file

@ -161,13 +161,6 @@ describe FactoryGirl::Factory do
end
end
it "inherits callbacks" do
@factory.add_callback(:after_stub) { |object| object.name = 'Stubby' }
child = FactoryGirl::Factory.new(:child, :parent => @factory.name)
child.ensure_compiled
child.callbacks.should_not be_empty
end
it "compiles when looking for attributes" do
@factory.declare_attribute(FactoryGirl::Declaration::Static.new("name", "value"))
@factory.attributes.size.should == 1