2012-11-26 61 views
0

請告訴我使用rspec測試模型的主要目的是什麼,我只測試驗證部分,如電子郵件和密碼等,有必要測試已定義的方法在模型中。如果你想測試方法(任何方法,而不僅僅是驗證方法)如何測試在模型中定義的模型和方法

https://github.com/thoughtbot/shoulda-matchers 

,你必須評估每一個響應: 謝謝

回答

0

如果您只是在測試驗證,你應該使用這個根據你定義的行爲的可能性。

describe "semaphore" do 
    describe "#turn_green" do 
    it "should turn green" do 
     subject.turn_green.should == "green" 
    end 
    it "should not turn red" do 
     subject.turn_green.should_not == "red" 
    end 
    end 
end