Class: HttpStub::Configurator::Scenario
- Inherits:
-
Object
- Object
- HttpStub::Configurator::Scenario
- Defined in:
- lib/http_stub/configurator/scenario.rb
Instance Method Summary collapse
- #activate! ⇒ Object
- #activate_scenarios!(*names) ⇒ Object
- #add_stub!(stub = nil, &block) ⇒ Object
- #add_stubs!(stubs) ⇒ Object
-
#initialize(name, default_stub_template) ⇒ Scenario
constructor
A new instance of Scenario.
- #to_hash ⇒ Object
Constructor Details
#initialize(name, default_stub_template) ⇒ Scenario
Returns a new instance of Scenario.
8 9 10 11 12 13 14 15 16 |
# File 'lib/http_stub/configurator/scenario.rb', line 8 def initialize(name, default_stub_template) @default_stub_template = default_stub_template @hash = { name: name, activated: false, stubs: [], triggered_scenario_names: [] }.with_indifferent_access end |
Instance Method Details
#activate! ⇒ Object
31 32 33 |
# File 'lib/http_stub/configurator/scenario.rb', line 31 def activate! @hash[:activated] = true end |
#activate_scenarios!(*names) ⇒ Object
27 28 29 |
# File 'lib/http_stub/configurator/scenario.rb', line 27 def activate_scenarios!(*names) @hash[:triggered_scenario_names].concat(names.flatten) end |
#add_stub!(stub = nil, &block) ⇒ Object
18 19 20 21 |
# File 'lib/http_stub/configurator/scenario.rb', line 18 def add_stub!(stub=nil, &block) resolved_stub = stub || build_stub(&block) @hash[:stubs] << resolved_stub.to_hash end |
#add_stubs!(stubs) ⇒ Object
23 24 25 |
# File 'lib/http_stub/configurator/scenario.rb', line 23 def add_stubs!(stubs) stubs.each { |stub| add_stub!(stub) } end |
#to_hash ⇒ Object
35 36 37 |
# File 'lib/http_stub/configurator/scenario.rb', line 35 def to_hash @hash end |