Class: RR::SpyVerification

Inherits:
Object
  • Object
show all
Includes:
DoubleDefinitions::DoubleDefinition::ArgumentDefinitionConstructionMethods, DoubleDefinitions::DoubleDefinition::TimesDefinitionConstructionMethods
Defined in:
lib/rr/spy_verification.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from DoubleDefinitions::DoubleDefinition::ArgumentDefinitionConstructionMethods

#with, #with_any_args, #with_no_args

Methods included from DoubleDefinitions::DoubleDefinition::TimesDefinitionConstructionMethods

#any_number_of_times, #at_least, #at_most, #never, #once, #times, #twice

Constructor Details

- (SpyVerification) initialize(subject, method_name, args)

Returns a new instance of SpyVerification



3
4
5
6
7
8
9
# File 'lib/rr/spy_verification.rb', line 3

def initialize(subject, method_name, args)
  @subject = subject
  @method_name = method_name.to_sym
  set_argument_expectation_for_args(args)
  @ordered = false
  once
end

Instance Attribute Details

- (Object) argument_expectation (readonly)

Returns the value of attribute argument_expectation



11
12
13
# File 'lib/rr/spy_verification.rb', line 11

def argument_expectation
  @argument_expectation
end

- (Object) method_name (readonly)

Returns the value of attribute method_name



11
12
13
# File 'lib/rr/spy_verification.rb', line 11

def method_name
  @method_name
end

- (Object) subject

Returns the value of attribute subject



12
13
14
# File 'lib/rr/spy_verification.rb', line 12

def subject
  @subject
end

- (Object) times_matcher

Returns the value of attribute times_matcher



11
12
13
# File 'lib/rr/spy_verification.rb', line 11

def times_matcher
  @times_matcher
end

Instance Method Details

- (Object) call



26
27
28
# File 'lib/rr/spy_verification.rb', line 26

def call
  (error = RR.recorded_calls.match_error(self)) && raise(error)
end

- (Object) ordered



17
18
19
20
# File 'lib/rr/spy_verification.rb', line 17

def ordered
  @ordered = true
  self
end

- (Boolean) ordered?

Returns:

  • (Boolean)


22
23
24
# File 'lib/rr/spy_verification.rb', line 22

def ordered?
  @ordered
end

- (Object) to_proc



30
31
32
33
34
# File 'lib/rr/spy_verification.rb', line 30

def to_proc
  lambda do
    call
  end
end