Parent

Files

Caricature::Verification

Describes a verification of a method call. This corresponds kind of to an assertion


Describes a verification of a method call. This corresponds kind of to an assertion

Public Class Methods

new(method_name, recorder, mode=:instance) click to toggle source

Initializes a new instance of a Verification

    # File lib/caricature/verification.rb, line 8
 8:     def initialize(method_name, recorder, mode=:instance)
 9:       @method_name, @args, @any_args, @recorder, @mode, @block_args = method_name, [], true, recorder, mode, nil
10:       init_plugin
11:     end

Public Instance Methods

allow_any_arguments() click to toggle source

allow any arguments ignore the argument constraint

    # File lib/caricature/verification.rb, line 35
35:     def allow_any_arguments
36:       @any_args = true
37:       self
38:     end
any_args?() click to toggle source

indicates whether this verification can be for any arguments

    # File lib/caricature/verification.rb, line 18
18:     def any_args?
19:       @any_args
20:     end
error() click to toggle source
    # File lib/caricature/verification.rb, line 45
45:     def error
46:       @recorder.error
47:     end
init_plugin() click to toggle source
    # File lib/caricature/verification.rb, line 13
13:     def init_plugin
14:       
15:     end
matches?(method_name, *args) click to toggle source

figure out if this argument variation matches the provided args.

    # File lib/caricature/verification.rb, line 41
41:     def matches?(method_name, *args)
42:       @method_name == method_name and any_args? or @args == args
43:     end
successful?() click to toggle source

indicate that this method verification is successful

    # File lib/caricature/bacon/integration.rb, line 43
43:     def successful?
44:       a = any_args? ? [:any] : @args
45:       res = @recorder.was_called?(@method_name, @block_args, @mode, *a)
46:       raise Caricature::ArgumentMatchError.new(:failed, self.error) unless res
47:       res
48:     end
successful?() click to toggle source

indicate that this method verification is successful

    # File lib/caricature/verification.rb, line 50
50:     def successful?
51:       a = any_args? ? [:any] : @args
52:       begin
53:         @recorder.was_called?(@method_name, @block_args, @mode, *a)
54:       rescue ArgumentError
55:         false
56:       end
57:     end
with(*args) click to toggle source

constrain this verification to the provided arguments

    # File lib/caricature/verification.rb, line 23
23:     def with(*args)
24:       @any_args = args.first.is_a?(Symbol) and args.first == :any
25:       @args = args 
26:      # @callback = b if b
27:       self
28:     end
with_block_args(*args) click to toggle source
    # File lib/caricature/verification.rb, line 30
30:     def with_block_args(*args)
31:       @block_args = args
32:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.