0

Rails 控制台中,我运行此命令

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

这将是一个空数组。

4

1 回答 1

0

我认为语法不完全正确。

FactoryGirl.create(:project_started)

是创建物品的方式。

于 2013-04-02T08:53:34.593 回答