Class: Matchi::BeFalse

Inherits:
Object
  • Object
show all
Defined in:
lib/matchi/be_false.rb

Overview

Untruth matcher.

Instance Method Summary collapse

Instance Method Details

#matches?Boolean

Boolean comparison between the actual value and the expected value.

Examples:

Is it false?

be_false = Matchi::BeFalse.new
be_false.matches? { false } # => true

Yield Returns:

  • (#object_id)

    the actual value to compare to the expected one.

Returns:

  • (Boolean)

    Comparison between actual and expected values.



13
14
15
# File 'lib/matchi/be_false.rb', line 13

def matches?
  false.equal?(yield)
end

#to_hHash

Returns a hash of one key-value pair with a key corresponding to the

matcher and a value corresponding to its initialize parameters.

Examples:

A FooBar matcher serialized into a hash.

matcher = Matchi::FooBar.new(42)
matcher.to_h # => { FooBar: 42 }

Returns:

  • (Hash)

    A hash of one key-value pair.



36
37
38
# File 'lib/matchi/be_false.rb', line 36

def to_h
  { BeFalse: [] }
end

#to_sString

Returns a string representing the matcher.

Examples:

The readable definition of a FooBar matcher.

matcher = Matchi::FooBar.new(42)
matcher.to_s # => "foo_bar 42"

Returns:

  • (String)

    A string representing the matcher.



24
25
26
# File 'lib/matchi/be_false.rb', line 24

def to_s
  'be_false'
end