zycte
6/20/2006 11:40:00 AM
You are using the variable test_id twice, once in the parameter list
and once as a temporary variable to assign the XML node. Once you say
test_id.text = test_id, test_id is already overwritten to be an xml
node with name 'testID'. So the text of the XML node testID is set to
<testID>, but with the brackets escaped because it is text inside XML.
On 2006-06-20 12:14:25 +0200, "aidy" <aidy.rutter@gmail.com> said:
> Hello,
>
> I my script I have a method call
>
> class ST_LTD_1 < Test::Unit::TestCase
> def test_st_ltd_1
> xml_logger(self.class, string_to_search)
> end
> end
>
>
> this is the invoked method
>
> def xml_logger (test_id, vp_text)
> doc = Document.new
> xmldecl = XMLDecl.default
> doc.add(xmldecl)
> test_result = doc.add_element 'testresults'
> test_id = test_result.add_element 'testID'
> test_id.text = test_id
> if verify_result_1(vp_text) then
> pass = test_id.add_element 'pass'
> pass.text = 'PASS'
> else
> pass = test_id.add_element 'fail'
> pass.text = 'FAIL!'
> end
> doc.write($stdout, 1)
> end
>
> this is the line of code where the calling class name should be passed
> to an XML node
>
> test_id.text = test_id
>
> However the XML produced is this
>
> <testresults>
> <testID><testID/><pass>PASS</pass>
> </testID>
> </testresults>
> and I am not sure so why?
> Thanks for the help
> Aidy