工厂女孩的数据结构

时间:2016-02-17 09:30:09

标签: ruby-on-rails ruby factory-bot

我正在尝试像FactoryGirl对象一样创建这个嵌套的哈希结构,以便我可以调用FactoryGirl.attributes_for(:my_object)

amount: total,
payment_method_nonce: params[:payment_method_nonce],
device_data: params[:device_data],
customer: {
  first_name: params[:first_name],
},
billing: {
      first_name: params[:first_name],
      last_name: params[:last_name],
}

到目前为止我已经

FactoryGirl.define do
  factory :my_object do
    amount nil 
    payment_method_nonce '132465'
    device_data 'device_data'
    customer {
      first_name 'Richard' 
    }
    billing {
      first_name 'Richard'
      last_name 'Lewis' 
    }
  end
end

我收到了语法错误,似乎无法正确使用

1 个答案:

答案 0 :(得分:4)

工厂女孩在其语法中使用const float AXIS_WIDTH = 2E6F; 。您需要two sets to get a hash

{}