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.
186 187 188 189 190 191 192 |
# File 'lib/smartest/matchers.rb', line 186 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
204 205 206 207 |
# File 'lib/smartest/matchers.rb', line 204 def by(expected_delta) @expected_delta = expected_delta self end |
#does_not_match?(actual) ⇒ Boolean
216 217 218 219 220 221 |
# File 'lib/smartest/matchers.rb', line 216 def does_not_match?(actual) run_change(actual) return false unless @callable negated_failures.empty? end |
#failure_message ⇒ Object
223 224 225 226 227 |
# File 'lib/smartest/matchers.rb', line 223 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
194 195 196 197 |
# File 'lib/smartest/matchers.rb', line 194 def from(expected) @expected_from = expected self end |
#matches?(actual) ⇒ Boolean
209 210 211 212 213 214 |
# File 'lib/smartest/matchers.rb', line 209 def matches?(actual) run_change(actual) return false unless @callable positive_failures.empty? end |
#negated_failure_message ⇒ Object
229 230 231 232 233 |
# File 'lib/smartest/matchers.rb', line 229 def return "expected a block not to change value" unless @callable "expected value not to change, but #{observed_description}" end |
#to(expected) ⇒ Object
199 200 201 202 |
# File 'lib/smartest/matchers.rb', line 199 def to(expected) @expected_to = expected self end |