How do I strip off the extra double quote or white space in the string when using assert_equal method

This is what I got for the second array when comparing: It was not
recognize separate element to put the double quote for each...

  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

<["Action Items",

"::::::::::::::::::",

"Open Alarms",

"Groomer Alarms",

"Warnings",

"Dead Hardware",

"Dead Channels"]>.

2 tests, 1 assertions, 1 failures, 0 errors

···

Exit code: 1

________________________________

From: Ban Hoang [mailto:bhoang@verance.com]
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

Hi Ben,

You are exactly correct: "it's adding it as a single

element instead of two, as you want."

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?

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).

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.

Thanks a lot for your help,

Ban

-----Original Message-----
From: Ben Bleything [mailto:ben@bleything.net]
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

On Thu, Aug 24, 2006, Ban Hoang wrote:

Thanks for your help, Ben!

I am confused on your assert_equal method:

assert_equal a.gsub(/['"]/, ''), b.gsub(/['"]/, '')

Is /['"]/ will strip out the quotes when comparing?

Notice that that call to assert_equal is wrapped inside a method. So

you would call

assert_equal_without_quotes( arr[0], $ie.frame.... )

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 :slight_smile:

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

Correct.

That why the expect is <[":: Select Site ::,!!Eastgate_Mall,\n"]

( missing separate double quotes)

Not only is it missing the quotes, but it's adding it as a single

element instead of two, as you want.

If your file looks like this:

-----

:: Select Site :: !!Something

:: Select Site :: !!Something else

...

-----

Then you'll need to determine how to parse that. Quick, dirty, and

untested:

-----

contents =

File.readlines('yourfile').each do |line|

  line =~ /(:: .*? ::)\s+(!!.*?)/

  label = $1

  value = $2

  contents << [$1, $2]

end

-----

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.

Again, it's probably easiest to just make it a real csv file :slight_smile:

Good luck!

Ben