我的Ruby On Rails单元测试在简单的字符串比较中失败,我找不到原因。Ruby on Rails中的字符串比较单元测试
在模型TestItem
,我有
doc = REXML::Document.new(data)
@bugtitle = doc.root.get_text("/bugzilla/bug/short_desc")
,其中数据是由Net::HTTP::post
请求返回一个XML字符串。数据看起来不错,如果我输出@bugtitle
它包含预期的字符串。在我的单元测试,我有
test "bugtitle" do
ti = testitems(:one)
assert_equal("different RID folder for gating x-ray correction images",ti.bugtitle)
end
令人惊讶的(至少对我来说)测试失败与下面的输出(从外壳逐字复制):
1) Failure:
test_bugtitle(TestTest) [unit/testitem_test.rb:7]:
<"different RID folder for gating x-ray correction images"> expected but was
<"different RID folder for gating x-ray correction images">.
我不知所措在这里,这个错误来自哪里,因为字符串看起来和我完全一样。对于它的价值,这是在Windows上使用rails 2.3.4和ruby 1.8.6(不要让我开始)。
哪个Ruby版本? – MBO 2009-12-01 10:03:02