# File lib/factory_girl/step_definitions.rb, line 29 def initialize(human_hash_to_attributes_hash, key, value) @human_hash_to_attributes_hash = human_hash_to_attributes_hash @key = key @value = value end
# File lib/factory_girl/step_definitions.rb, line 35 def association @human_hash_to_attributes_hash.associations.detect {|association| association.name == @key } end
# File lib/factory_girl/step_definitions.rb, line 39 def association_instance return unless association if attributes_hash = nested_attribute_hash factory.build_class.first(:conditions => attributes_hash.attributes(FindAttributes)) or FactoryGirl.create(association.factory, attributes_hash.attributes) end end
# File lib/factory_girl/step_definitions.rb, line 50 def factory FactoryGirl.factory_by_name(association.factory) end
# File lib/factory_girl/step_definitions.rb, line 54 def nested_attribute_hash attribute, value = @value.split(':', 2) return if value.blank? HumanHashToAttributeHash.new({ attribute => value }, factory.associations) end