Class: Spec::Matchers::BeInstanceOf

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/matchers/be_instance_of.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ BeInstanceOf

Returns a new instance of BeInstanceOf.



4
5
6
# File 'lib/spec/matchers/be_instance_of.rb', line 4

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



13
14
15
# File 'lib/spec/matchers/be_instance_of.rb', line 13

def description
  "be an instance of #{@expected}"
end

#failure_message_for_shouldObject



17
18
19
# File 'lib/spec/matchers/be_instance_of.rb', line 17

def failure_message_for_should
  "expected instance of #{@expected}, got #{@actual.inspect}"
end

#failure_message_for_should_notObject



21
22
23
# File 'lib/spec/matchers/be_instance_of.rb', line 21

def failure_message_for_should_not
  "expected #{@actual.inspect} not to be an instance of #{@expected}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/spec/matchers/be_instance_of.rb', line 8

def matches?(actual)
  @actual = actual
  @actual.instance_of?(@expected)
end