class HttpStub::Configurator::Server
Public Class Methods
new(state)
click to toggle source
# File lib/http_stub/configurator/server.rb, line 12 def initialize(state) @state = state @server_stub_template = HttpStub::Configurator::Stub::Template.new end
Public Instance Methods
add_scenario!(name) { |scenario| ... }
click to toggle source
# File lib/http_stub/configurator/server.rb, line 29 def add_scenario!(name, &_block) scenario = HttpStub::Configurator::Scenario.new(name, @server_stub_template) yield scenario @state.add_scenario(scenario) scenario end
add_scenario_with_one_stub!(name, stub=nil, &block)
click to toggle source
# File lib/http_stub/configurator/server.rb, line 36 def add_scenario_with_one_stub!(name, stub=nil, &block) add_scenario!(name) do |scenario| built_stub = stub || scenario.build_stub built_stub.invoke(block.arity == 2 ? scenario : nil, &block) if block_given? scenario.add_stub!(built_stub) end end
add_stub!(stub=nil, &block)
click to toggle source
# File lib/http_stub/configurator/server.rb, line 44 def add_stub!(stub=nil, &block) resolved_stub = stub || self.build_stub(&block) @state.add_stub(resolved_stub) end
add_stubs!(stubs)
click to toggle source
# File lib/http_stub/configurator/server.rb, line 49 def add_stubs!(stubs) stubs.each { |stub| add_stub!(stub) } end
endpoint_template(&block)
click to toggle source
# File lib/http_stub/configurator/server.rb, line 25 def endpoint_template(&block) HttpStub::Configurator::EndpointTemplate.new(self, @server_stub_template, &block) end
request_defaults=(args)
click to toggle source
# File lib/http_stub/configurator/server.rb, line 17 def request_defaults=(args) @server_stub_template.match_requests(args) end
response_defaults=(args)
click to toggle source
# File lib/http_stub/configurator/server.rb, line 21 def response_defaults=(args) @server_stub_template.respond_with(args) end