2013-05-29 31 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)