Method: Arrow::TestCase#assert_has_ivar
- Defined in:
- lib/arrow/testcase.rb
#assert_has_ivar(sym, object) ⇒ Object
Assert that the specified object
has an instance variable which matches the specified sym
. The ‘@’ at the beginning of the sym
will be prepended if not present.
399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/arrow/testcase.rb', line 399 def assert_has_ivar( sym, object ) sym = "@#{sym}" unless /^@/ =~ sym.to_s msg = "Object <%s> expected to have an instance variable <%s>" % [ object.inspect, sym ] assert_block( msg ) { object.instance_variables.include?( sym.to_s ) } rescue Test::Unit::AssertionFailedError => err cutframe = err.backtrace.reverse.find {|frame| /assert_has_ivar/ =~ frame } firstIdx = (err.backtrace.rindex( cutframe )||0) + 1 Kernel.raise( err, err., err.backtrace[firstIdx..-1] ) end |