Class: HttpStub::Server::Scenario::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/server/scenario/registry.rb

Instance Method Summary collapse

Constructor Details

#initialize(scenarios) ⇒ Registry

Returns a new instance of Registry.


9
10
11
# File 'lib/http_stub/server/scenario/registry.rb', line 9

def initialize(scenarios)
  @scenario_registry = HttpStub::Server::Registry.new("scenario", scenarios)
end

Instance Method Details

#stubs_activated_by(scenario, logger) ⇒ Object


13
14
15
16
17
18
19
# File 'lib/http_stub/server/scenario/registry.rb', line 13

def stubs_activated_by(scenario, logger)
  scenario.stubs + scenario.triggered_scenarios.map(&:name).map do |triggered_scenario_name|
    triggered_scenario = @scenario_registry.find(triggered_scenario_name, logger)
    raise HttpStub::Server::Scenario::NotFoundError, triggered_scenario_name unless triggered_scenario
    stubs_activated_by(triggered_scenario, logger)
  end.flatten
end