2013-04-02 22 views
0

old_spec.rb早該寶石allow_value方法

it { should allow_value(:nil).for(:invoice_type) } 
it { should allow_value(:customer_invoice).for(:invoice_type) } 
it { should allow_value(:creative_invoice).for(:invoice_type) } 
it { should_not allow_value(:other).for(:invoice_type) } 

我在規範文件中的這些代碼,我將它們轉換像下面。

new_spec.rb

it { should ensure_inclusion_of(:invoice_type).in_array(
    [:nil,:customer_invoice,:creative_invoice]) } 

我想知道的是,在第二個文件(new_spec.rb)我必須在此線。

it { should_not allow_value(:other).for(:invoice_type) } 

回答

0

基於如何ensure_inclusion_of作品的描述,你不應該需要明確防止其他值。

當然,這將是很容易檢查自己...