Class Spec::Expectations::Should::Change
In: lib/spec/expectations/should/change.rb
Parent: Base

Methods

by   evaluate_change   execute_change   from   message   new   to  

Public Class methods

[Source]

    # 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

Public Instance methods

[Source]

    # 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

[Source]

    # 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

[Source]

    # 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

[Source]

    # 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

[Source]

    # File lib/spec/expectations/should/change.rb, line 21
21:         def message
22:           @message.nil? ? 'result' : @message
23:         end

[Source]

    # File lib/spec/expectations/should/change.rb, line 38
38:         def to(value)
39:           if @after_change != value
40:             fail_with_message "#{message} should have been changed to #{value.inspect}, but is now #{@after_change.inspect}"
41:           end
42:           self
43:         end

[Validate]