I'm trying to use FactoryGirl
to build a Hash
that returns something like this:
=> {"3"=>"1", "6"=>"Word"}
I'm getting close but not 100% there yet...
The first factory definition i tried looked like this:
factory :faqtory, class: Hash do |f|
f.ignore do
fake_word Faker::Lorem.word
end
f.sequence(1.to_s) { |n| n }
f.send(2.to_s, fake_word.to_s.capitalize)
initialize_with { attributes.stringify_keys }
end
Unfortunately this doesn't work:
1.9.3p448 :001 > FactoryGirl.build :faqtory
ArgumentError: Trait not registered: fake_word
After that didn't work i assumed the call to fake_word
needed to be in a block but that makes no difference.
Any suggestions?
"2"
.. Same output as i pasted for @vimsha pastie.org/8559316 . I am sure this has to do with "lazy attributes" ( github.com/thoughtbot/factory_girl/blob/master/…) but not sure how to implement a solution. – Denitadenitrate