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

Renamed Factory#name to Factory#factory_name so you can have name attributes without using #add_attribute

This commit is contained in:
Joe Ferris 2008-06-23 18:17:01 -04:00
parent 51ef8f90da
commit d63ed8fa34
2 changed files with 6 additions and 6 deletions

View file

@ -4,7 +4,7 @@ class Factory
self.factories = {} self.factories = {}
self.sequences = {} self.sequences = {}
attr_reader :name attr_reader :factory_name
# Defines a new factory that can be used by the build strategies (create and # Defines a new factory that can be used by the build strategies (create and
# build) to build new objects. # build) to build new objects.
@ -61,12 +61,12 @@ class Factory
end end
def build_class #:nodoc: def build_class #:nodoc:
@build_class ||= @options[:class] || name.to_s.classify.constantize @build_class ||= @options[:class] || factory_name.to_s.classify.constantize
end end
def initialize (name, options = {}) #:nodoc: def initialize (name, options = {}) #:nodoc:
options.assert_valid_keys(:class) options.assert_valid_keys(:class)
@name = name @factory_name = name
@options = options @options = options
@static_attributes = {} @static_attributes = {}

View file

@ -82,8 +82,8 @@ class FactoryTest < Test::Unit::TestCase
@factory = Factory.new(@name) @factory = Factory.new(@name)
end end
should "have a name" do should "have a factory name" do
assert_equal @name, @factory.name assert_equal @name, @factory.factory_name
end end
should "have a build class" do should "have a build class" do