2013-05-29 44 views
1

我試圖做到這一點user.abc_id.should == 0並報錯了說如何使用黃瓜比較零?

expected: 0 
got: "0" (using ==) (RSpec::Expectations::ExpectationNotMetError) 
+2

的問題是串VS號。不幸的是,你爲這個問題提供了零環境。 –

回答

0

的問題是戴夫在評論說是串與數量。如果您look at the rspec documentation你會看到

a == b # object equivalence - a and b have the same value with type conversions 

一個string objectinteger object不等同

所以你可以嘗試像

a.eql?(b) # object equivalence - a and b have the same value 

在你的情況,這可能工作

user.abc_id.should eql(0)