Class: HttpStub::Configurator::Server
- Inherits:
-
Object
- Object
- HttpStub::Configurator::Server
- Defined in:
- lib/http_stub/configurator/server.rb
Instance Method Summary collapse
- #add_scenario!(name) {|scenario| ... } ⇒ Object
- #add_scenario_with_one_stub!(name, stub = nil, &block) ⇒ Object
- #add_stub!(stub = nil, &block) ⇒ Object
- #add_stubs!(stubs) ⇒ Object
- #endpoint_template(&block) ⇒ Object
-
#initialize(state) ⇒ Server
constructor
A new instance of Server.
- #request_defaults=(args) ⇒ Object
- #response_defaults=(args) ⇒ Object
Constructor Details
Instance Method Details
#add_scenario!(name) {|scenario| ... } ⇒ Object
29 30 31 32 33 |
# 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) end |
#add_scenario_with_one_stub!(name, stub = nil, &block) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/http_stub/configurator/server.rb', line 35 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) ⇒ Object
43 44 45 46 |
# File 'lib/http_stub/configurator/server.rb', line 43 def add_stub!(stub=nil, &block) resolved_stub = stub || self.build_stub(&block) @state.add_stub(resolved_stub) end |
#add_stubs!(stubs) ⇒ Object
48 49 50 |
# File 'lib/http_stub/configurator/server.rb', line 48 def add_stubs!(stubs) stubs.each { |stub| add_stub!(stub) } end |
#endpoint_template(&block) ⇒ Object
25 26 27 |
# 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) ⇒ Object
17 18 19 |
# File 'lib/http_stub/configurator/server.rb', line 17 def request_defaults=(args) @server_stub_template.match_requests(args) end |
#response_defaults=(args) ⇒ Object
21 22 23 |
# File 'lib/http_stub/configurator/server.rb', line 21 def response_defaults=(args) @server_stub_template.respond_with(args) end |