Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails gem是否应该允许使用价值法_Ruby On Rails_Rspec_Shoulda - Fatal编程技术网

Ruby on rails gem是否应该允许使用价值法

Ruby on rails gem是否应该允许使用价值法,ruby-on-rails,rspec,shoulda,Ruby On Rails,Rspec,Shoulda,旧规范rb 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) } 我在我的规范文

旧规范rb

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) }
我在我的规范文件中有这些代码,我像下面那样转换它们

新规范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) }

根据对
如何确保
包含的描述,您不需要明确阻止其他值

当然,这将是非常容易为自己检查这个