मैं अपने मॉडल, उनमें से एक होने के परीक्षण के लिए चाहिये rspec matchers में से कुछ का उपयोग कर रहा बनाने के लिए:चाहिये rspec matchers: पर =>:
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)
सत्यापन ट्रिगर नहीं किया जा रहा है beca इसका उपयोग केवल एक अद्यतन पर चलता है, मैं एक बनाम बनाम एक अद्यतन पर इन कंधे matchers का उपयोग कैसे कर सकते हैं?
धन्यवाद @endium। इसी प्रकार, 'subject {FactoryGirl.create (: user)}' का उपयोग ':: अद्यतन '-केवल सत्यापनों का परीक्षण करने के लिए किया जा सकता है। – scarver2