Class: Minitest::StubChain
- Inherits:
-
Object
- Object
- Minitest::StubChain
- Defined in:
- lib/minitest/stub_chain.rb
Overview
respresentaion of zero or more stub blocks around one or more test assertions
Constant Summary collapse
- NOT_CALLABLE_ERR =
'StubChain#call takes a callable argument'- MUST_NOT_CALL_A_BLOCK_ERR =
'StubChain#call takes a callable argument which must not call a block'
Instance Attribute Summary collapse
-
#stubs ⇒ Object
readonly
Returns the value of attribute stubs.
Class Method Summary collapse
Instance Method Summary collapse
- #call(test_code_proc) ⇒ Object
-
#initialize(stubs = []) ⇒ StubChain
constructor
A new instance of StubChain.
Constructor Details
#initialize(stubs = []) ⇒ StubChain
Returns a new instance of StubChain.
13 14 15 |
# File 'lib/minitest/stub_chain.rb', line 13 def initialize(stubs = []) @stubs = *stubs end |
Instance Attribute Details
#stubs ⇒ Object (readonly)
Returns the value of attribute stubs.
11 12 13 |
# File 'lib/minitest/stub_chain.rb', line 11 def stubs @stubs end |
Class Method Details
.stubproc(klass, *args, any_instance: false, **kwargs) ⇒ Object
17 18 19 20 21 |
# File 'lib/minitest/stub_chain.rb', line 17 def self.stubproc(klass, *args, any_instance: false, **kwargs) return proc { |&blk| klass.stub(*args, **kwargs) { blk.call } } unless any_instance proc { |&blk| klass.stub_any_instance(*args, **kwargs) { blk.call } } end |
Instance Method Details
#call(test_code_proc) ⇒ Object
23 24 25 26 |
# File 'lib/minitest/stub_chain.rb', line 23 def call(test_code_proc) validate(test_code_proc) call_recursive [*stubs, test_code_proc] end |