Seems simple, but haven't been able to figure out how to get this to work.
In model.rb:
def Model
attr_accessor :width,
:height
def initialize params
@width = params[:width]
@height = params[:height]
...
In factory file models.rb
:
FactoryGirl.define do
factory :model do
height 5
width 7
end
end
Setting the attributes in the factory method throws an error wrong number of arguments (0 for 1)
Working in Ruby 1.9.3 without Rails, using Factory.build
. FactoryGirl 4.1.
EDIT: More info:
Using RSpec: let(:model) { FactoryGirl.build :model }
Factory.build
? Could you post the full contents of your factory definition, including anyafter_build
orafter_create
hooks? – Teapot