モデルをテストするために、Shoulda rspec マッチャをいくつか使用しています。そのうちの 1 つは次のとおりです。
describe Issue do
it { should_not allow_value("test").for(:priority) }
end
これに関する私の問題は、私のモデルでの検証が次のようになることです。
validates_format_of :priority, :with => /^(Low|Normal|High|Urgent)$/, :on => :update
したがって、このテストを実行すると、次のようになります。
1) 'Issue should not allow priority to be set to "test"' FAILED
Expected errors when priority is set to "test", got errors: category is invalid (nil)title can't be blank (nil)profile_id can't be blank (nil)
更新時にのみ実行されるため、検証はトリガーされません。更新と作成でこれらのマッチャーを使用するにはどうすればよいですか?