Class: Smartest::ChangeMatcher
- Inherits:
-
Object
- Object
- Smartest::ChangeMatcher
- Defined in:
- lib/smartest/matchers.rb
Constant Summary collapse
- UNSET =
Object.new
Instance Method Summary collapse
- #by(expected_delta) ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message ⇒ Object
- #from(expected) ⇒ Object
-
#initialize(value_block) ⇒ ChangeMatcher
constructor
A new instance of ChangeMatcher.
- #matches?(actual) ⇒ Boolean
- #negated_failure_message ⇒ Object
- #to(expected) ⇒ Object
Constructor Details
#initialize(value_block) ⇒ ChangeMatcher
Returns a new instance of ChangeMatcher.
452 453 454 455 456 457 458 |
# File 'lib/smartest/matchers.rb', line 452 def initialize(value_block) @value_block = value_block @expected_from = UNSET @expected_to = UNSET @expected_delta = UNSET reset_result end |
Instance Method Details
#by(expected_delta) ⇒ Object
470 471 472 473 |
# File 'lib/smartest/matchers.rb', line 470 def by(expected_delta) @expected_delta = expected_delta self end |
#does_not_match?(actual) ⇒ Boolean
482 483 484 485 486 487 |
# File 'lib/smartest/matchers.rb', line 482 def does_not_match?(actual) run_change(actual) return false unless @callable negated_failures.empty? end |
#failure_message ⇒ Object
489 490 491 492 493 |
# File 'lib/smartest/matchers.rb', line 489 def return "expected a block to change value" unless @callable "expected value to #{expected_description}, but #{observed_description}#{failed_modifier_description}" end |
#from(expected) ⇒ Object
460 461 462 463 |
# File 'lib/smartest/matchers.rb', line 460 def from(expected) @expected_from = expected self end |
#matches?(actual) ⇒ Boolean
475 476 477 478 479 480 |
# File 'lib/smartest/matchers.rb', line 475 def matches?(actual) run_change(actual) return false unless @callable positive_failures.empty? end |
#negated_failure_message ⇒ Object
495 496 497 498 499 |
# File 'lib/smartest/matchers.rb', line 495 def return "expected a block not to change value" unless @callable "expected value not to change, but #{observed_description}" end |
#to(expected) ⇒ Object
465 466 467 468 |
# File 'lib/smartest/matchers.rb', line 465 def to(expected) @expected_to = expected self end |