Class: ErgomentumRspec::Matchers::Array::StrictlyIncreasing

Inherits:
Object
  • Object
show all
Defined in:
lib/ergomentum_rspec/matchers/array/be_strictly_increasing.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



25
26
27
# File 'lib/ergomentum_rspec/matchers/array/be_strictly_increasing.rb', line 25

def description
  "be strictly increasing"
end

#failure_messageObject



17
18
19
# File 'lib/ergomentum_rspec/matchers/array/be_strictly_increasing.rb', line 17

def failure_message
  "expected array #{@actual.inspect} to be strictly increasing"
end

#failure_message_when_negatedObject



21
22
23
# File 'lib/ergomentum_rspec/matchers/array/be_strictly_increasing.rb', line 21

def failure_message_when_negated
  "expected array #{@actual.inspect} to not be strictly increasing"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/ergomentum_rspec/matchers/array/be_strictly_increasing.rb', line 11

def matches?(actual)
  @actual = actual
  derivative = actual.each_cons(2).map { |x, y| y <=> x }
  derivative.all?(&:positive?)
end