【发布时间】:2013-12-16 21:44:01
【问题描述】:
我有这个代码:
FactoryGirl.define do
factory :gimme_a_hash, class: Hash do
one 'the number 1'
two 'the number 2'
end
end
它返回一个看起来像这样的哈希:
1.9.3p448 :003 > FactoryGirl.build : gimme_a_hash
=> {:one=>"the number 1", :two=>"the number 2"}
如何创建一个工厂以返回带有字符串化数字作为键的哈希?
理想情况下,我希望返回以下哈希:
=> { "1"=>"the number 1", "2"=>"the number 2"}
谢谢!
【问题讨论】:
标签: ruby-on-rails ruby testing factory-bot