Class: Section9::UnitTest::VerifyNotObject

Inherits:
VerifyBaseObject show all
Defined in:
lib/section9/unittest.rb

Constant Summary

Constants inherited from VerifyBaseObject

Section9::UnitTest::VerifyBaseObject::DEPTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(testcase, actual = nil, location = nil, &block) ⇒ VerifyNotObject

Returns a new instance of VerifyNotObject.



329
330
331
332
333
334
# File 'lib/section9/unittest.rb', line 329

def initialize(testcase, actual=nil, location=nil, &block)
  @testcase = testcase
  @actual = actual
  @block = block
  @location = location
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



401
402
403
404
405
# File 'lib/section9/unittest.rb', line 401

def method_missing(method_name, *args)
  _wrap {
    _method_missing(false, method_name, *args)
  }
end

Instance Attribute Details

#locationObject

Returns the value of attribute location.



335
336
337
# File 'lib/section9/unittest.rb', line 335

def location
  @location
end

Instance Method Details

#<(expected) ⇒ Object



337
# File 'lib/section9/unittest.rb', line 337

def < (expected); _wrap { @testcase.assert_operator(@actual, :>=, expected) } end

#<=(expected) ⇒ Object



338
# File 'lib/section9/unittest.rb', line 338

def <=(expected); _wrap { @testcase.assert_operator(@actual, :>,  expected) } end

#==(expected) ⇒ Object



342
# File 'lib/section9/unittest.rb', line 342

def ==(expected); _wrap { @testcase.assert_not_equal(expected, @actual) } end

#=~(expected) ⇒ Object



343
# File 'lib/section9/unittest.rb', line 343

def =~(expected); _wrap { @testcase.assert_no_match(expected, @actual) } end

#>(expected) ⇒ Object



339
# File 'lib/section9/unittest.rb', line 339

def > (expected); _wrap { @testcase.assert_operator(@actual, :<=, expected) } end

#>=(expected) ⇒ Object



340
# File 'lib/section9/unittest.rb', line 340

def >=(expected); _wrap { @testcase.assert_operator(@actual, :<,  expected) } end

#called?(arg) ⇒ Boolean

Returns:

  • (Boolean)


395
396
397
398
399
# File 'lib/section9/unittest.rb', line 395

def called?(arg)
  _wrap {
    raise NoMethodError.new("'called?()' is not available with '.NOT'.")
  }
end

#dir_exist?Boolean

Returns:

  • (Boolean)


382
383
384
385
386
# File 'lib/section9/unittest.rb', line 382

def dir_exist?
  _wrap {
    raise NoMethodError.new("'dir_exist?()' is not available with '.NOT'. please use '.NOT.exist?' instead.")
  }
end

#exist?Boolean

Returns:

  • (Boolean)


388
389
390
391
392
393
# File 'lib/section9/unittest.rb', line 388

def exist?
  _wrap {
    ! File.exist?(@actual)  or
      @testcase.flunk "#{File.directory?(@actual) ? 'Directory' : 'File'} '#{@actual}' exists unexpectedly."
  }
end

#file_exist?Boolean

Returns:

  • (Boolean)


376
377
378
379
380
# File 'lib/section9/unittest.rb', line 376

def file_exist?
  _wrap {
    raise NoMethodError.new("'file_exist?()' is not available with '.NOT'. please use '.NOT.exist?' instead.")
  }
end

#in_delta?(expected, delta) ⇒ Boolean

Returns:

  • (Boolean)


355
# File 'lib/section9/unittest.rb', line 355

def in_delta?   (expected, delta); _wrap { @testcase.assert_not_in_delta(expected, @actual, delta) } end

#instance_of?(expected) ⇒ Boolean

Returns:

  • (Boolean)


354
# File 'lib/section9/unittest.rb', line 354

def instance_of?(expected); _wrap { @testcase.assert_not_instance_of(expected, @actual) } end

#kind_of?(expected) ⇒ Boolean

def is_a? (expected); _wrap { @testcase.assert_not_kind_of(expected, @actual) } end

Returns:

  • (Boolean)


353
# File 'lib/section9/unittest.rb', line 353

def kind_of?    (expected); _wrap { @testcase.assert_not_kind_of(expected, @actual) } end

#nil?Boolean

Returns:

  • (Boolean)


350
# File 'lib/section9/unittest.rb', line 350

def nil?        ()        ; _wrap { @testcase.assert_not_nil(@actual) } end

#raise?Boolean

Returns:

  • (Boolean)


358
359
360
361
362
363
364
365
366
367
# File 'lib/section9/unittest.rb', line 358

def raise?
  _wrap {
    #if block_given?
    #  @testcase.assert_nothing_raised { yield }
    #else
      proc_obj = @block || @actual
      @testcase.assert_nothing_raised { proc_obj.call }
    #end
  }
end

#respond_to?(expected) ⇒ Boolean

Returns:

  • (Boolean)


356
# File 'lib/section9/unittest.rb', line 356

def respond_to? (expected); _wrap { @testcase.assert_not_respond_to(@actual, expected) } end

#same?(expected) ⇒ Boolean

Returns:

  • (Boolean)


351
# File 'lib/section9/unittest.rb', line 351

def same?       (expected); _wrap { @testcase.assert_not_same(expected, @actual) } end

#throw?Boolean

Returns:

  • (Boolean)


369
370
371
372
373
374
# File 'lib/section9/unittest.rb', line 369

def throw?
  _wrap {
    proc_obj = @block || @actual
    @testcase.assert_nothing_thrown { proc_obj.call }
  }
end