Class: RSpec::Bash::StubBehavior
- Inherits:
-
Object
- Object
- RSpec::Bash::StubBehavior
- Defined in:
- lib/rspec/bash/stub_behavior.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#body ⇒ Object
Returns the value of attribute body.
Instance Method Summary collapse
- #applicable?(args) ⇒ Boolean
- #apply!(args) ⇒ Object
- #context_free? ⇒ Boolean
-
#initialize(args: nil, body:, charges: 1, subshell: true) ⇒ StubBehavior
constructor
A new instance of StubBehavior.
- #requires_subshell? ⇒ Boolean
- #usable? ⇒ Boolean
Constructor Details
#initialize(args: nil, body:, charges: 1, subshell: true) ⇒ StubBehavior
Returns a new instance of StubBehavior.
6 7 8 9 10 11 |
# File 'lib/rspec/bash/stub_behavior.rb', line 6 def initialize(args: nil, body:, charges: 1, subshell: true) @args = args @body = body @subshell = subshell @charges = charges end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
4 5 6 |
# File 'lib/rspec/bash/stub_behavior.rb', line 4 def args @args end |
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/rspec/bash/stub_behavior.rb', line 4 def body @body end |
Instance Method Details
#applicable?(args) ⇒ Boolean
17 18 19 |
# File 'lib/rspec/bash/stub_behavior.rb', line 17 def applicable?(args) @args == args end |
#apply!(args) ⇒ Object
29 30 31 32 |
# File 'lib/rspec/bash/stub_behavior.rb', line 29 def apply!(args) @charges -= 1 @body.call(args) end |
#context_free? ⇒ Boolean
21 22 23 |
# File 'lib/rspec/bash/stub_behavior.rb', line 21 def context_free? @args.nil? end |
#requires_subshell? ⇒ Boolean
25 26 27 |
# File 'lib/rspec/bash/stub_behavior.rb', line 25 def requires_subshell? @subshell end |
#usable? ⇒ Boolean
13 14 15 |
# File 'lib/rspec/bash/stub_behavior.rb', line 13 def usable? @charges > 0 end |