Parent

Included Modules

Files

Caricature::Expectation

A description of an expectation. An expectation has the power to call the proxy method or completely ignore it

Attributes

method_name[R]

gets the method_name to which this expectation needs to listen to

args[R]

the arguments that this expectation needs to be constrained by

error_args[R]

the error_args that this expectation will raise an error with

return_value[R]

the value that this expecation will return when executed

super[R]

indicator for the mode to call the super :before, :after and nil

callback[R]

contains the callback if one is given

Public Class Methods

new(method_name, args, error_args, return_value, super_mode, callback) click to toggle source

Initializes a new instance of an expectation

     # File lib/caricature/expectation.rb, line 105
105:     def initialize(method_name, args, error_args, return_value, super_mode, callback)
106:       @method_name, @args, @error_args, @return_value, @super, @callback =
107:               method_name, args, error_args, return_value, super_mode, callback
108:       @any_args = true
109:     end

Public Instance Methods

call_super?() click to toggle source

indicates whether super needs to be called somewhere

     # File lib/caricature/expectation.rb, line 127
127:     def call_super?
128:       !@super.nil?
129:     end
execute(*margs) click to toggle source

executes this expectation with its configuration

     # File lib/caricature/expectation.rb, line 137
137:     def execute(*margs)
138:       ags = any_args? ? (margs.empty? ? :any : margs) : args
139:       actual_raise *@error_args if has_error_args?    
140:       callback.call(*ags) if has_callback?
141:       return return_value if has_return_value? 
142:       nil
143:     end
has_callback?() click to toggle source

indicates whether this expecation has a callback it needs to execute

     # File lib/caricature/expectation.rb, line 132
132:     def has_callback? 
133:       !@callback.nil?
134:     end
has_error_args?() click to toggle source

indicates whether this expecation will raise an event.

     # File lib/caricature/expectation.rb, line 112
112:     def has_error_args?
113:       !@error_args.nil?
114:     end
has_return_value?() click to toggle source

indicates whether this expectation will return a value.

     # File lib/caricature/expectation.rb, line 117
117:     def has_return_value?
118:       !@return_value.nil?
119:     end
inspect() click to toggle source

(Not documented)

     # File lib/caricature/expectation.rb, line 149
149:     def inspect
150:       to_s
151:     end
super_before?() click to toggle source

call the super before the expectation

     # File lib/caricature/expectation.rb, line 122
122:     def super_before?
123:       @super == :before
124:     end
to_s() click to toggle source

(Not documented)

     # File lib/caricature/expectation.rb, line 145
145:     def to_s
146:       "<Caricature::Expecation, method_name: #{method_name}, args: #{args}, error args: #{error_args}>"
147:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.