case statement not being picked up

A

aidy

Hi,

This is my code and I have printed out some de-bug statements. I
haven't a clue why the task = 'validate' switch statement is not being
executed.

<code>
class Form

def initialize
#see if file exists, what file or we going to use?
#@filename = "search.txt"
@filename = "validate.txt"
end

def enter_data
task = nil
count = 1
flag = 0

read_in_test_data.each { |x|
line = x.chomp
#debug
p "line = #{x.chomp}"
case line
when /^\*+ TESTID_\d+$/
p line.gsub(/\*/, '')
flag += 1
if flag > 1
$ie.back
count = 1
end
when /^Address:$/
task = :address
when /^Country:$/
task = :country
when /^Search-Results:$/
task = :search
when /^Validate:$/
task = :validate
when /^Expected-Result:$/
task = :verify
when /^END:$/
$ie.close
else
p "the task = #{task}"
case task
when :address
$ie.text_field:)name, "AL#{count}").set(line)
count += 1
when :country
$ie.text_field:)name, 'C1').set(line)
when :validate
$ie.button:)value, 'Validate').click
when :search
$ie.text_field:)name, 'NR1').set(line)
$ie.button:)value, 'Search').click
when :verify
if $ie.contains_text(line)
p line, "PASS"
else
p line, "FAIL"
end
else
#whatever
end
end
}
end


def read_in_test_data
#check if file exists and give date of last change
File.readlines(@filename, "\n" )
end
private:read_in_test_data
end
<code>


debug statements
"line = *********************************************** TESTID_100"
" TESTID_100"
"line = Address:"
"line = Choyce Close"
"the task = address"
"line = Country:"
"line = GB"
"the task = country"
"line = Validate:"
"line = Expected-Result:"
"line = Is Complete: "
"the task = verify"

the file being read

*********************************************** TESTID_100
Address:
Choyce Close
Country:
GB
Validate:
Expected-Result:
Is Complete:
false
Confidence Level:
0
Address:
Postal Authority Formatted Address:
Choyce Close
United Kingdom
*********************************************** TESTID_200

etc

Much appreciated

Aidy
 
A

aidy

I am still struggling without a visual debugger within an IDE, even
though I have ordered a license of Arachno Ruby it may take a couple of
days for that license to be sent.

The Arachno developers have promised that the debugger will work with
Ruby 184x

Cheers

Aidy
 
C

Carlos

aidy said:
Hi,

This is my code and I have printed out some de-bug statements. I
haven't a clue why the task = 'validate' switch statement is not being
executed.

<code>
[...]

Check your indentation. You read a line. If you recognize it, you set
the task. If you don't recognize it, you print "the task = ..." and do
something related to the task.

Since "Expected-Result" is recognized, you never get to process the
validate action. You need to intercalate a blank line or something (or
change your algorithm).
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top