Sha256: 115d355569b1b8b0e1b588dd8bfed3c9c8e00899d237a2cf92ec458a5bf084dc

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

# Provides the '==' assertion method.
#
# Example:
#
#     insist { "foo" } == "foo"
module Insist::Comparators
  include Insist::Assert

  # value == expected
  def ==(expected)
    assert(value == expected,
           "Expected #{expected.inspect}, but got #{value.inspect}")
  end # def ==

  # value <= expected
  def <=(expected)
    assert(value <= expected,
           "Expected #{value.inspect} <= #{expected.inspect}")
  end # def <=
 
  # value >= expected
  def >=(expected)
    assert(value >= expected,
           "Expected #{value.inspect} >= #{expected.inspect}")
  end # def >=

  # value > expected
  def >(expected)
    assert(value > expected,
           "Expected #{value.inspect} > #{expected.inspect}")
  end # def >

  # value < expected
  def <(expected)
    assert(value < expected,
           "Expected #{value.inspect} < #{expected.inspect}")
  end # def <
 
  # value != expected
  def !=(expected)
    assert(value != expected,
           "Expected #{value.inspect} != #{expected.inspect}")
  end # def !=

  # value =~ pattern
  def =~(pattern)
    assert(value =~ pattern,
           "Expected #{value.inspect} =~ #{pattern.inspect}")
  end # def =~

  # value !~ pattern
  def !~(pattern)
    assert(value !~ pattern,
           "Expected #{value.inspect} !~ #{pattern.inspect}")
  end # def !~
end # module Insist::Comparators

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
insist-0.0.4 lib/insist/comparators.rb