Class: ApiSim::AppBuilder
- Inherits:
-
Object
- Object
- ApiSim::AppBuilder
- Defined in:
- lib/api_sim/app_builder.rb
Constant Summary collapse
- NOT_FOUND =
[nil, [404, {}, 'NOT FOUND']]
Instance Method Summary collapse
- #configure_dynamic_endpoint(http_method, route, response_logic) ⇒ Object
- #configure_endpoint(http_method, route, response_body, response_code = 200, headers = {}, schema_string = '') ⇒ Object
- #configure_matcher_endpoint(http_method, route, matchers_to_responses) ⇒ Object
- #endpoint_configurations ⇒ Object
- #rackapp ⇒ Object
Instance Method Details
#configure_dynamic_endpoint(http_method, route, response_logic) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/api_sim/app_builder.rb', line 29 def configure_dynamic_endpoint(http_method, route, response_logic) endpoint_configurations.push( Matchers::DynamicRequestMatcher.new( http_method: http_method, route: route, default: true, response_generator: response_logic ) ) end |
#configure_endpoint(http_method, route, response_body, response_code = 200, headers = {}, schema_string = '') ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/api_sim/app_builder.rb', line 15 def configure_endpoint(http_method, route, response_body, response_code=200, headers={}, schema_string='') endpoint_configurations.push( Matchers::StaticRequestMatcher.new( http_method: http_method, route: route, response_code: response_code, headers: headers, default: true, response_body: response_body, schema: schema_string ) ) end |
#configure_matcher_endpoint(http_method, route, matchers_to_responses) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/api_sim/app_builder.rb', line 40 def configure_matcher_endpoint(http_method, route, matchers_to_responses) matchers_to_responses.each do |matcher, response| endpoint_configurations.push( Matchers::RequestBodyMatcher.new( http_method: http_method, route: route, response_code: response[0], headers: response[1], response_body: response[2], default: true, body_matches: matcher ) ) end end |
#endpoint_configurations ⇒ Object
56 57 58 |
# File 'lib/api_sim/app_builder.rb', line 56 def endpoint_configurations @endpoint_configurations ||= [] end |
#rackapp ⇒ Object
8 9 10 11 12 13 |
# File 'lib/api_sim/app_builder.rb', line 8 def rackapp config = self Class.new(BuiltApp) do endpoints config.endpoint_configurations end end |