Class | Spec::Expectations::Should::Change |
In: |
lib/spec/expectations/should/change.rb
|
Parent: | Base |
# File lib/spec/expectations/should/change.rb, line 6 6: def initialize(target, receiver=nil, message=nil, &block) 7: @block = block 8: @target = target 9: @receiver = receiver 10: @message = message 11: execute_change 12: evaluate_change 13: end
# File lib/spec/expectations/should/change.rb, line 45 45: def by(expected_delta) 46: if actual_delta != expected_delta 47: fail_with_message "#{message} should have been changed by #{expected_delta}, but was changed by #{actual_delta}" 48: end 49: self 50: end
# File lib/spec/expectations/should/change.rb, line 25 25: def evaluate_change 26: if @before_change == @after_change 27: fail_with_message "#{message} should have changed, but is still #{@after_change.inspect}" 28: end 29: end
# File lib/spec/expectations/should/change.rb, line 15 15: def execute_change 16: @before_change = @block.nil? ? @receiver.send(@message) : @block.call 17: @target.call 18: @after_change = @block.nil? ? @receiver.send(@message) : @block.call 19: end
# File lib/spec/expectations/should/change.rb, line 31 31: def from(value) 32: if @before_change != value 33: fail_with_message "#{message} should have initially been #{value.inspect}, but was #{@before_change.inspect}" 34: end 35: self 36: end