Saturday 15 June 2013

String comparison in Ruby on Rails unit-test -


My Ruby On Rail Unit test fails in a simple string comparison and I can not understand why.

In Model TestItem , I have

  doc = REXML :: Document.new (data) @bugtitle = doc.root.get_text ( "/ Bugzilla / Bg / short_desc")  

Where data is returned by an XML string Net :: HTTP :: Post request. The data looks good, and if I have the required string in the output @bugtitle in my unit-test, I have to do

  test "bugle" = ti = testitems (: A) assert_equal ("separate RID folder for X-ray correction images", Ti.bugtitle) end surprisingly (at least for me) the test fails with the following output (shell copy from the wordship): < / P> 
  1) Failure: test_bugtitle (TestTest) [unit / testim_stest. RB: 7]: & lt; "Separate RID folder to get X-ray correction images" & gt; Expected "separate RID folders to get X-ray correction images" & gt;  

I am at a disadvantage from where this error occurs because the string looks similar to me. What is the price, it is with Windows 2.3.4 and with Ruby 1.8.6 (I did not initially get it).

These two look identical, but only after you #inspect See representation. You should check the encoding and binary presentations (if Ruby is 1.9), this is probably the problem.


No comments:

Post a Comment