How do I define a FactoryGirl factory that returns a Hash with stringed keys?

Viewed 6012

I have this code:

FactoryGirl.define do
  factory :gimme_a_hash, class: Hash do
    one 'the number 1'
    two 'the number 2'
  end
end

It returns a hash that looks like:

1.9.3p448 :003 > FactoryGirl.build : gimme_a_hash
 => {:one=>"the number 1", :two=>"the number 2"}

How do I create a factory that returns a Hash with stringified numbers as keys?

Ideally i'd like to have the following hash returned:

 => { "1"=>"the number 1", "2"=>"the number 2"}

Thank you!

2 Answers
Related