Parent

Files

Caricature::EventVerification

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

Public Class Methods

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

Initializes a new instance of a Verification

    # File lib/caricature/clr/event_verification.rb, line 8
 8:     def initialize(event_name, recorder, mode=:instance)
 9:       @event_name, @args, @any_args, @recorder, @mode = event_name, [], true, recorder, mode
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/clr/event_verification.rb, line 31
31:     def allow_any_arguments
32:       @any_args = true
33:       self
34:     end
any_args?() click to toggle source

indicates whether this verification can be for any arguments

    # File lib/caricature/clr/event_verification.rb, line 18
18:     def any_args?
19:       @any_args
20:     end
error() click to toggle source
    # File lib/caricature/clr/event_verification.rb, line 41
41:     def error
42:       @recorder.event_error
43:     end
init_plugin() click to toggle source
    # File lib/caricature/clr/event_verification.rb, line 13
13:     def init_plugin
14:       
15:     end
matches?(event_name, *args) click to toggle source

figure out if this argument variation matches the provided args.

    # File lib/caricature/clr/event_verification.rb, line 37
37:     def matches?(event_name, *args)
38:       @event_name == event_name and (any_args? or @args == args)
39:     end
successful?() click to toggle source

indicate that this event verification is successful

    # File lib/caricature/bacon/integration.rb, line 56
56:     def successful?
57:       a = any_args? ? [:any] : @args
58:       res = @recorder.event_raised?(@event_name, @mode, *a)
59:       raise Caricature::ArgumentMatchError.new(:failed, self.error) unless res
60:       res
61:     end
successful?() click to toggle source

indicate that this method verification is successful

    # File lib/caricature/clr/event_verification.rb, line 46
46:     def successful?
47:       a = any_args? ? [:any] : @args
48:       begin
49:         @recorder.event_raised?(@event_name, @mode, *a)
50:       rescue ArgumentError
51:         false
52:       end
53:     end
with(*args) click to toggle source

constrain this verification to the provided arguments

    # File lib/caricature/clr/event_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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.