From: Ban Hoang Date: 2006-08-25T02:40:20+09:00 Subject: Re: How do I strip off the extra double quote or white space in the string when using assert_equal method ------_=_NextPart_001_01C6C7A4.5EB4F50C Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This is what I got for the second array when comparing: It was not recognize separate element to put the double quote for each... =20 =20 1) Failure: test__02_DropDown_list_verified(TC_pulldownBoxVerified) [Assert_equal_From_File.rb:55]: <["Action Items :::::::::::::::::: Open Alarms Groomer Alarms Warnings Dead Hardware Dead Channels\n"]> expected but was =20 <["Action Items", "::::::::::::::::::", "Open Alarms", "Groomer Alarms", "Warnings", "Dead Hardware", "Dead Channels"]>. =20 2 tests, 1 assertions, 1 failures, 0 errors >Exit code: 1 =20 ________________________________ From: Ban Hoang [mailto:bhoang@verance.com]=20 Sent: Thursday, August 24, 2006 10:07 AM To: ruby-talk ML Subject: Re: How do I strip off the extra double quote or white space in the string when using assert_equal method =20 Hi Ben, =20 You are exactly correct: "it's adding it as a single element instead of two, as you want." =20 It is my main problem: if the second line array[1] has 7 elements, it's still adding as a single element? How do I fix it? =20 If I use assert_equal and put the details for each element in the assert method and compare directly. It works OK (please look at Assert_equalOK attached file). =20 If I try to use external cvs file, it has the problem and can not separate the link detail as different element! I attached the csv file and the my assert_equal_from_File for you to review. =20 Thanks a lot for your help, =20 Ban=20 =20 =20 -----Original Message----- From: Ben Bleything [mailto:ben@bleything.net]=20 Sent: Thursday, August 24, 2006 9:01 AM To: ruby-talk ML Subject: Re: How do I strip off the extra double quote or white space in the string when using assert_equal method =20 On Thu, Aug 24, 2006, Ban Hoang wrote: > Thanks for your help, Ben! >=20 > I am confused on your assert_equal method: >=20 > assert_equal a.gsub(/['"]/, ''), b.gsub(/['"]/, '') >=20 > Is /['"]/ will strip out the quotes when comparing? =20 Notice that that call to assert_equal is wrapped inside a method. So you would call =20 assert_equal_without_quotes( arr[0], $ie.frame.... ) =20 I think the real problem is that you need to figure out how to parse your file, though. You call it a csv but it's not. My suggestion would be to fix it so it is :) =20 > I think my actual problem is when reading into an array and compare, it > did not separate :: Select Site :: as one field and :: > !!Eastgate_Mall to another field for double quotes =20 Correct. =20 > That why the expect is <[":: Select Site ::,!!Eastgate_Mall,,,,,\n"] > ( missing separate double quotes) =20 Not only is it missing the quotes, but it's adding it as a single element instead of two, as you want. =20 If your file looks like this: =20 ----- :: Select Site :: !!Something :: Select Site :: !!Something else ... ----- =20 Then you'll need to determine how to parse that. Quick, dirty, and untested: =20 ----- contents =3D [] =20 File.readlines('yourfile').each do |line| line =3D~ /(:: .*? ::)\s+(!!.*?)/ =20 label =3D $1 value =3D $2 =20 contents << [$1, $2] end ----- =20 There's probably a better regex you could use, but the bottom line is, you need to extract the values from your file instead of just grabbing each line. =20 Again, it's probably easiest to just make it a real csv file :) =20 Good luck! Ben =20 ------_=_NextPart_001_01C6C7A4.5EB4F50C--