我收到此方法不存在的错误,但这似乎相当基本,我不确定为什么会收到错误?
it { should validate_presence_of :role } # This is OK.
Failure/Error:
it { should validate_inclusion_of :role, :in => %w[one two three ] }
NoMethodError:
undefined method `validate_inclusion_of' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fad7474f9b8>
对于代码:
class User < ActiveRecord::Base
validates_presence_of :role
validates_inclusion_of :role, :in => [one, two three] ]
http://apidock.com/rails/ActiveModel/Validations/ClassMethods/validates_inclusion_of