Module: Fakes::ArgBehaviour
Instance Attribute Summary collapse
-
#arg_matcher ⇒ Object
Returns the value of attribute arg_matcher.
-
#return_value ⇒ Object
Returns the value of attribute return_value.
-
#times_called ⇒ Object
Returns the value of attribute times_called.
Instance Method Summary collapse
- #and_return(item) ⇒ Object
- #capture_args(args) ⇒ Object
- #initialize_matcher_using(args) ⇒ Object
- #matches?(args) ⇒ Boolean
- #process ⇒ Object
- #throws(exception) ⇒ Object
- #was_called_with?(args) ⇒ Boolean
Instance Attribute Details
#arg_matcher ⇒ Object
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_value ⇒ Object
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_called ⇒ Object
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
22 23 24 |
# File 'lib/fakes/arg_behaviour.rb', line 22 def matches?(args) return @arg_matcher.matches?(args) end |
#process ⇒ Object
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
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 |