在 rails console 中,我运行此命令
bill = Bill.last
bill.bill_extras
结果就是这样。
[#<BillExtra id: 141, bill_id: 621, content: "extra fee", prize: #<BigDecimal:7fa2e37d4f50,'0.248E3',9(18)>, created_at: "2012-08-02 04:48:12", updated_at: "2012-08-02 04:50:41">]
在规范文件中,
require 'spec_helper'
require 'pry'
describe Bill do
before(:all) do
@project=Factory(:project_started)
@customer_bill=Factory(:customer_invoice, :project => @project)
@creavite_bill=Factory(:creative_invoice, :project => @project)
@bill_extra=Factory.build(:bill_extra, :bill => @customer_bill)
end
binding.pry
end
当我调试时,在pry中运行这些命令,
@customer_bill.bill_extras
它将是一个空数组。
答案 0 :(得分:0)
我认为语法并不完全正确。
FactoryGirl.create(:project_started)
是创建项目的方式。