Class: Matchi::BeInstanceOf
- Inherits:
-
Object
- Object
- Matchi::BeInstanceOf
- Defined in:
- lib/matchi/rspec/be_instance_of.rb
Overview
Type/class matcher.
Instance Method Summary collapse
-
#initialize(expected) ⇒ BeInstanceOf
constructor
Initialize the matcher with an object.
-
#matches? ⇒ Boolean
Comparison between actual and expected values.
-
#to_h ⇒ Hash
Returns a hash of one key-value pair with a key corresponding to the matcher and a value corresponding to its initialize parameters.
-
#to_s ⇒ String
Returns a string representing the matcher.
Constructor Details
#initialize(expected) ⇒ BeInstanceOf
Initialize the matcher with an object.
11 12 13 |
# File 'lib/matchi/rspec/be_instance_of.rb', line 11 def initialize(expected) @expected = expected end |
Instance Method Details
#matches? ⇒ Boolean
Returns Comparison between actual and expected values.
23 24 25 |
# File 'lib/matchi/rspec/be_instance_of.rb', line 23 def matches? yield.instance_of?(@expected) end |
#to_h ⇒ Hash
Returns a hash of one key-value pair with a key corresponding to the
matcher and a value corresponding to its initialize parameters.
38 39 40 |
# File 'lib/matchi/rspec/be_instance_of.rb', line 38 def to_h { BeInstanceOf: [@expected] } end |
#to_s ⇒ String
Returns a string representing the matcher.
30 31 32 |
# File 'lib/matchi/rspec/be_instance_of.rb', line 30 def to_s "be_instance_of #{@expected.inspect}" end |