class ErgomentumRspec::Matchers::Array::MonotonicallyDecreasing

Public Instance Methods

description() click to toggle source
# File lib/ergomentum_rspec/matchers/array/be_monotonically_decreasing.rb, line 25
def description
  "be monotonically decreasing"
end
failure_message() click to toggle source
# File lib/ergomentum_rspec/matchers/array/be_monotonically_decreasing.rb, line 17
def failure_message
  "expected array #{@actual.inspect} to be monotonically decreasing"
end
failure_message_when_negated() click to toggle source
# File lib/ergomentum_rspec/matchers/array/be_monotonically_decreasing.rb, line 21
def failure_message_when_negated
  "expected array #{@actual.inspect} to not be monotonically decreasing"
end
matches?(actual) click to toggle source
# File lib/ergomentum_rspec/matchers/array/be_monotonically_decreasing.rb, line 11
def matches?(actual)
  @actual = actual
  derivative = actual.each_cons(2).map { |x, y| y <=> x }
  derivative.all? { |v| v <= 0 }
end