Class: ErgomentumRspec::Matchers::Array::MonotonicallyDecreasing
- Inherits:
-
Object
- Object
- ErgomentumRspec::Matchers::Array::MonotonicallyDecreasing
- Defined in:
- lib/ergomentum_rspec/matchers/array/be_monotonically_decreasing.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_decreasing.rb', line 25 def description "be monotonically decreasing" end |
#failure_message ⇒ Object
17 18 19 |
# File 'lib/ergomentum_rspec/matchers/array/be_monotonically_decreasing.rb', line 17 def "expected array #{@actual.inspect} to be monotonically decreasing" end |
#failure_message_when_negated ⇒ Object
21 22 23 |
# File 'lib/ergomentum_rspec/matchers/array/be_monotonically_decreasing.rb', line 21 def "expected array #{@actual.inspect} to not be monotonically decreasing" end |
#matches?(actual) ⇒ Boolean
11 12 13 14 15 |
# 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 |