Class: Whitestone::Assertion::Identity

Inherits:
Base show all
Defined in:
lib/whitestone/assertion_classes.rb

Overview

class Assertion::FloatEqual

Instance Method Summary collapse

Methods inherited from Base

#block

Methods included from Guards

#args_or_block_one_only, #block_required, #no_block_allowed, #one_argument, #two_arguments, #two_or_three_arguments, #type_check

Constructor Details

#initialize(mode, *args, &block) ⇒ Identity

Returns a new instance of Identity.



338
339
340
341
342
# File 'lib/whitestone/assertion_classes.rb', line 338

def initialize(mode, *args, &block)
  super
  @obj1, @obj2 = two_arguments(args)
  no_block_allowed
end

Instance Method Details

#messageObject



346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/whitestone/assertion_classes.rb', line 346

def message
  String.new.tap { |str|
    case @mode
    when :assert
      str << Col["Identity test failed -- the two objects are NOT the same"].yb
      str << Col["\n  Object 1 id: ", @obj1.object_id].fmt('yb,rb')
      str << Col["\n  Object 2 id: ", @obj2.object_id].fmt('yb,rb')
    when :negate
      str << Col["Identity test failed -- the two objects ARE the same"].yb
      str << Col["\n  Object id: ", @obj1.object_id].fmt('yb,rb')
    end
  }
end

#runObject



343
344
345
# File 'lib/whitestone/assertion_classes.rb', line 343

def run
  @obj1.object_id == @obj2.object_id
end