class HttpStub::Server::Session::Session

Attributes

id[R]

Public Class Methods

new(id, scenario_registry, initial_stubs) click to toggle source
# File lib/http_stub/server/session/session.rb, line 9
def initialize(id, scenario_registry, initial_stubs)
  @id                  = id
  @scenario_registry   = scenario_registry
  @stub_registry       = HttpStub::Server::Stub::Registry.new(initial_stubs)
  @stub_match_registry = HttpStub::Server::Registry.new("stub match")
  @stub_miss_registry  = HttpStub::Server::Registry.new("stub miss")
end

Public Instance Methods

activate_scenario!(name, logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 21
def activate_scenario!(name, logger)
  found_scenario = @scenario_registry.find(name, logger)
  raise HttpStub::Server::Scenario::NotFoundError, name unless found_scenario
  activated_stubs = @scenario_registry.stubs_activated_by(found_scenario, logger)
  @stub_registry.concat(activated_stubs, logger)
end
add_match(match, logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 44
def add_match(match, logger)
  @stub_match_registry.add(match, logger)
  match.stub.triggers.scenario_names.each { |scenario_name| activate_scenario!(scenario_name, logger) }
  match.stub.triggers.stubs.each { |stub| add_stub(stub, logger) }
end
add_miss(miss, logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 58
def add_miss(miss, logger)
  @stub_miss_registry.add(miss, logger)
end
add_stub(stub, logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 28
def add_stub(stub, logger)
  @stub_registry.add(stub, logger)
end
find_stub(id, logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 32
def find_stub(id, logger)
  @stub_registry.find(id, logger)
end
last_match(args, logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 54
def last_match(args, logger)
  @stub_match_registry.find(args, logger)
end
match(request, logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 40
def match(request, logger)
  @stub_registry.match(request, logger)
end
matches() click to toggle source
# File lib/http_stub/server/session/session.rb, line 50
def matches
  @stub_match_registry.all
end
matches?(id, _logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 17
def matches?(id, _logger)
  id == @id
end
misses() click to toggle source
# File lib/http_stub/server/session/session.rb, line 62
def misses
  @stub_miss_registry.all
end
reset(logger) click to toggle source
# File lib/http_stub/server/session/session.rb, line 66
def reset(logger)
  @stub_miss_registry.clear(logger)
  @stub_match_registry.clear(logger)
  @stub_registry.reset(logger)
end
stubs() click to toggle source
# File lib/http_stub/server/session/session.rb, line 36
def stubs
  @stub_registry.all
end