在我的模型中,我有以下要测试的内容:
UNIT_TYPES = [ 'seconds', 'minutes', 'hours', ]
validates_inclusion_of :unit_type, :in => UNIT_TYPES, :allow_blank => true
并使用我放的应该匹配器:
it { should ensure_inclusion_of(:unit_type).in_array(UNIT_TYPES) }
但是为什么我会收到这个错误?
失败:
1) Price inclusions
Failure/Error: it { should ensure_inclusion_of(:unit_type).in_array(UNIT_TYPES) }
NameError:
uninitialized constant UNIT_TYPES
# ./spec/models/price_spec.rb:39:in `block (3 levels) in <top (required)>'