tags:

views:

59

answers:

3

I want to use the assertions and put valuidations in my ruby code (e.g: checking if a zip file is created, label is present, message in the text area, etc). I have put a few assert statements like assert @selenium.is_text_present(textMessage), but they don't work.

Please let me know if any ruby gem for assertions is to be installed.

A: 

http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html

Helps u

Please, post an excerpt from the content you link to to StackOverflow. And, again, this doesn't help, since Harry is not unit-testing.
Pavel Shved
+2  A: 

For simple asserts, you're probably best off rolling your own assert method taking a block:

ruby-1.9.1-p378 > class AssertionError < RuntimeError
ruby-1.9.1-p378 ?>  end
 => nil 
ruby-1.9.1-p378 > def assert &block
ruby-1.9.1-p378 ?>  raise AssertionError unless yield
ruby-1.9.1-p378 ?>  end
 => nil 
ruby-1.9.1-p378 > assert { 1 > 0 }
 => nil 
ruby-1.9.1-p378 > assert { 5 == 12 }
AssertionError: AssertionError
    from (irb):8:in `assert'
    from (irb):11
    from /Users/mr/.rvm/rubies/ruby-1.9.1-p378/bin/irb:17:in `<main>'
Mark Rushakoff