Module: Fakes::ArgBehaviour

Included in:
ArgSet, IgnoreSet
Defined in:
lib/fakes/arg_behaviour.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arg_matcherObject

Returns the value of attribute arg_matcher.



3
4
5
# File 'lib/fakes/arg_behaviour.rb', line 3

def arg_matcher
  @arg_matcher
end

#return_valueObject

Returns the value of attribute return_value.



3
4
5
# File 'lib/fakes/arg_behaviour.rb', line 3

def return_value
  @return_value
end

#times_calledObject

Returns the value of attribute times_called.



3
4
5
# File 'lib/fakes/arg_behaviour.rb', line 3

def times_called
  @times_called
end

Instance Method Details

#and_return(item) ⇒ Object



9
10
11
# File 'lib/fakes/arg_behaviour.rb', line 9

def and_return(item)
  @return_value = item
end

#capture_args(args) ⇒ Object



17
18
19
20
# File 'lib/fakes/arg_behaviour.rb', line 17

def capture_args(args)
  @times_called += 1
  @called_args = args
end

#initialize_matcher_using(args) ⇒ Object



5
6
7
# File 'lib/fakes/arg_behaviour.rb', line 5

def initialize_matcher_using(args)
  @arg_matcher = ArgMatchFactory.create_arg_matcher_using(args)
end

#matches?(args) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/fakes/arg_behaviour.rb', line 22

def matches?(args)
  return @arg_matcher.matches?(args)
end

#processObject



30
31
32
33
34
35
# File 'lib/fakes/arg_behaviour.rb', line 30

def process
  return @return_value unless @exception
  if @exception
    raise @exception
  end
end

#throws(exception) ⇒ Object



13
14
15
# File 'lib/fakes/arg_behaviour.rb', line 13

def throws(exception)
  @exception = exception
end

#was_called_with?(args) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/fakes/arg_behaviour.rb', line 26

def was_called_with?(args)
  ArgMatchFactory.create_arg_matcher_using(args).matches?(@called_args)
end