2013-04-02 256 views
0

軌控制檯,我運行此命令工廠女孩嵌套屬性

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 

當我調試,運行在撬這些命令,

@customer_bill.bill_extras 

這將是一個空數組。

回答

0

我認爲這裏的語法不太正確。

FactoryGirl.create(:project_started)

是製造物品的方式。