Use shoulda_matchers
In recent versions of shoulda-matchers
(at least as of v2.7.0), you can do:
expect(subject).to validate_inclusion_of(:active).in_array(%w[Y N])
This tests that the array of acceptable values in the validation exactly matches this spec.
In earlier versions, >= v1.4 , shoulda_matchers
supports this syntax:
it {should ensure_inclusion_of(:active).in_array(%w[Y N]) }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…