私はこれをやろうとしていuser.abc_id.should == 0ますが、エラーが発生します
expected: 0
got: "0" (using ==) (RSpec::Expectations::ExpectationNotMetError)
私はこれをやろうとしていuser.abc_id.should == 0ますが、エラーが発生します
expected: 0
got: "0" (using ==) (RSpec::Expectations::ExpectationNotMetError)
問題は、デイブがコメントで言ったように、文字列と数値です。rspecのドキュメントを見ると、
a == b # object equivalence - a and b have the same value with type conversions
astring objectとinteger objectは同等ではありません。
したがって、次のようなものを試すことができます
a.eql?(b) # object equivalence - a and b have the same value
あなたの場合、これはうまくいくかもしれません
user.abc_id.should eql(0)