Forum: Ruby Re: undefined method `add_assertion' for nil:NilClass

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Paatsch, Bernd (Guest)
on 2006-03-22 04:39
(Received via mailing list)
I started with ruby about 6 weeks ago. So I am pretty new. The code I
contains out of 4 files and works only with a specific underlying
application, which I manipulate through the code. Maybe I am
the use of assertions. I thought that assertions help raising errors. I
don't want to run a Unittest. So maybe my approach is wrong?
I removee < Test::Unit::TestCase

Now I get:
TEST FAILED.undefined method `assert' for #<WebAC::BPUtils:0x2c2e270>

My code:
    require 'test/unit/assertions'
    require 'test/unit'

  # more code
  $clsBPUtils =
  # more code

  class BPUtils
  	require 'test/unit/assertions'

    def initialize
        # empty

    def bpVerifyPopupWindowOpen( ieCont, verify)
	  assert( ieCont.contains_text( verify) )
	  puts("TEST PASSED. Found test string 'Programming Ruby' ")
   rescue => e
         puts("TEST FAILED." + e.message + "\n" +
Robert D. (Guest)
on 2006-03-22 11:41
(Received via mailing list)
Hi Bernd

if your parameter ieCont (I hope that does not mean what I am afraid it
mean ;)
is nil it cannot respond to the method contains_text and that seems to
your problem.
It seems you did not pass an object of the expected type.

It does not really have anything to do with assert, only that the stack
trace becomes a little bit confusing sometimes.


On 3/22/06, Paatsch, Bernd <removed_email_address@domain.invalid> wrote:
> TEST FAILED.undefined method `assert' for #<WebAC::BPUtils:0x2c2e270>
>   class BPUtils
>    rescue => e
> Subject: Re: undefined method `add_assertion' for nil:NilClass
> > TEST FAILED.undefined method `add_assertion' for nil:NilClass
> > result
> "Ruby for Rails" chapters now available
> from Manning Early Access Program!

Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein
This topic is locked and can not be replied to.