TypeError: nil is not a symbol error when running tests

Discussion in 'Ruby' started by Arti Singh, Nov 9, 2009.

  1. Arti Singh

    Arti Singh Guest

    TypeError: nil is not a symbol error when runing test.

    Has anyone seen this error before? I have added the method that gives
    me trouble below


    Running the Class :


    s_name="ItemName"+Time.Now()


    dc=CreateItem.new(s_name)


    with the definition


    class CreateItem< Test::Unit::TestCase


    attr_accessor :s_name
    s_name="SH Test"




    def setup

    login("Browser")

    end#setup




    def initialize(name)
    @s_name=name
    end #def initialize(dc)


    #~ #Test to create a Item
    def test_createdc(name)
    #@$browser.open("https://index.html")
    @s_name=name

    s
    xpath="//div[@class='view
    container]//label[contains(text(),'#{s_name}')]/.."
    assert($browser.element?(xpath))
    array=getElement(xpath)
    #Assert that the element has been created, check for the name
    of the item
    getElementName(array,$s_name)
    getCreatedbyName(array,$username)


    end #createdc


    end #class createitem
    --
    Posted via http://www.ruby-forum.com/.
     
    Arti Singh, Nov 9, 2009
    #1
    1. Advertising

  2. Arti Singh wrote:
    > TypeError: nil is not a symbol error when runing test.
    >
    > Has anyone seen this error before?


    Post the exact exception report using copy-paste, because it will
    include a backtrace, and the first line will give the line number where
    the error occurred.

    If this is inside a library, look at subsequent lines of the backtrace
    until you find a line in your own source. Then indicate which line of
    the source code this is.

    If I had to guess where the problem is, I would say

    getElementName(array,$s_name)

    because you don't appear to have initialised the global variable $s_name
    to anything, and therefore this would be the same as

    getElementName(array,nil)

    (@s_name and $s_name are two completely different things)
    --
    Posted via http://www.ruby-forum.com/.
     
    Brian Candler, Nov 9, 2009
    #2
    1. Advertising

  3. Arti Singh

    Arti Singh Guest

    Brian Candler wrote:

    > If I had to guess where the problem is, I would say
    >
    > getElementName(array,$s_name)
    >
    > because you don't appear to have initialised the global variable $s_name
    > to anything, and therefore this would be the same as
    >
    > getElementName(array,nil)
    >
    > (@s_name and $s_name are two completely different things)


    You were right, I did not assign a value to the global variable
    $username, so I did that and the test ran. Thank you very much.
    --
    Posted via http://www.ruby-forum.com/.
     
    Arti Singh, Nov 9, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candler

    puts nil generates "nil\n"

    Brian Candler, Nov 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    113
  2. John Carter
    Replies:
    64
    Views:
    648
    Klaus Stein
    May 19, 2005
  3. ako...

    a == nil or a.nil?

    ako..., Nov 22, 2005, in forum: Ruby
    Replies:
    6
    Views:
    145
    Douglas Livingstone
    Nov 23, 2005
  4. Christoffer Sawicki
    Replies:
    5
    Views:
    263
    Christoffer Sawicki
    Sep 2, 2006
  5. Replies:
    1
    Views:
    142
    Peña, Botp
    May 27, 2008
Loading...

Share This Page