2011-12-02 16 views
0

我試圖按照與RSpec的TDD教程包含以下行:更改RSpec的錯誤檢查

it 'must have a first_name' do 
    p = Person.new 
    p.should_not be_valid 
    p.errors.on(:first_name).should_not be_nil 
end 

但是我在我的測試中收到以下消息:

未定義的方法'on'for #ActiveModel :: Errors:0x007fde0c3eceb0>

什麼是寫上面代碼的正確方法。

回答

2

正確的功能是errors_on。所以該行應該是

p.errors_on(:first_name).should_not be_nil