Class: Outbacker::OutbackerStub
- Inherits:
-
Object
- Object
- Outbacker::OutbackerStub
- Includes:
- Outbacker
- Defined in:
- lib/test_support/outbacker_stub.rb
Constant Summary
Constants included from Outbacker
DEFAULT_BLACKLIST, DEFAULT_WHITELIST, VERSION
Instance Method Summary collapse
-
#initialize(method_name = nil, outcome_key = nil, *block_args) ⇒ OutbackerStub
constructor
A new instance of OutbackerStub.
- #stub_outbacked_method(method_name, outcome_key, *block_args) ⇒ Object
- #stub_simple_method(method_name, result) ⇒ Object
Methods included from Outbacker
apply_blacklist, apply_whitelist, included, #with
Constructor Details
#initialize(method_name = nil, outcome_key = nil, *block_args) ⇒ OutbackerStub
Returns a new instance of OutbackerStub.
27 28 29 30 31 |
# File 'lib/test_support/outbacker_stub.rb', line 27 def initialize(method_name=nil, outcome_key=nil, *block_args) if method_name && outcome_key stub_outbacked_method(method_name, outcome_key, *block_args) end end |
Instance Method Details
#stub_outbacked_method(method_name, outcome_key, *block_args) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/test_support/outbacker_stub.rb', line 33 def stub_outbacked_method(method_name, outcome_key, *block_args) define_singleton_method(method_name, ->(*args, &outcome_handlers) { with(outcome_handlers) do |outcomes| outcomes.handle outcome_key, *block_args end }) end |
#stub_simple_method(method_name, result) ⇒ Object
41 42 43 44 45 |
# File 'lib/test_support/outbacker_stub.rb', line 41 def stub_simple_method(method_name, result) define_singleton_method(method_name) do result end end |