I believe the issue is with your player model requiring an argument at initialization.
Try this instead:
class Player
attr_accessor :name
def initialize(options={})
@name = options[:name]
end
end
When FactoryGirl
initializes the model, it will initialize with a nil
name
attribute like this:
1.9.3p448 :013 > Player.new
#<Player:0x000000017acff0 @name=nil>
You can then define the name as you intend in your commented out line. This will also allow you to initialize a Player
with a hash like:
1.9.3p448 :012 > Player.new(name: "something")
#<Player:0x00000003b53008 @name="something">