A
私の検証では、必須フィールドは次のいずれかにのみ設定できることが保証されていますR
。
モデル内:
validates :status_code, inclusion: { in: %w(A R) }
RSpec には、次の仕様があります。
it { expect(@car).to allow_value("A", "R").for(:status_code) }
it { expect(@car).to_not allow_value(nil, "").for(:status_code) }
最初の RSpec はパスしますが、2 番目の RSpec でエラーが発生します。
Failure/Error: it { expect(@car).to_not allow_value(nil, "").for(:status_code) }
Expected errors when status_code is set to "", got no errors
私は何が欠けていますか?RSpec 3.1 を使用しています。