Class: ErgomentumRspec::Matchers::Array::MonotonicallyIncreasing
- Inherits:
-
Object
- Object
- ErgomentumRspec::Matchers::Array::MonotonicallyIncreasing
- Defined in:
- lib/ergomentum_rspec/matchers/array/be_monotonically_increasing.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #matches?(actual) ⇒ Boolean
Instance Method Details
#description ⇒ Object
25 26 27 |
# File 'lib/ergomentum_rspec/matchers/array/be_monotonically_increasing.rb', line 25 def description "be monotonically increasing" end |
#failure_message ⇒ Object
17 18 19 |
# File 'lib/ergomentum_rspec/matchers/array/be_monotonically_increasing.rb', line 17 def "expected array #{@actual.inspect} to be monotonically increasing" end |
#failure_message_when_negated ⇒ Object
21 22 23 |
# File 'lib/ergomentum_rspec/matchers/array/be_monotonically_increasing.rb', line 21 def "expected array #{@actual.inspect} to not be monotonically increasing" end |
#matches?(actual) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/ergomentum_rspec/matchers/array/be_monotonically_increasing.rb', line 11 def matches?(actual) @actual = actual derivative = actual.each_cons(2).map { |x, y| y <=> x } derivative.all? { |v| v >= 0 } end |