Class: Restspec::Endpoints::EndpointDSL
- Inherits:
-
Struct
- Object
- Struct
- Restspec::Endpoints::EndpointDSL
- Defined in:
- lib/restspec/endpoints/dsl.rb
Overview
The Endpoint DSL is what should be used inside an endpoint block. Its major responsability is to define endpoint behavior.
Defined Under Namespace
Classes: ExampleOrValue
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#headers ⇒ Object
A mutable hash containing the headers for the endpoint.
-
#method(method) ⇒ Object
Defines what the HTTP method will be.
-
#no_schema ⇒ Object
Remove the schema of the current endpoint.
-
#path(path) ⇒ Object
Defines what the path will be.
-
#schema(name, options = {}) ⇒ Object
Defines what the schema will be.
-
#url_param(param, &value_or_type_block) ⇒ Object
This set url parameters for the endpoint.
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint
243 244 245 |
# File 'lib/restspec/endpoints/dsl.rb', line 243 def endpoint @endpoint end |
Instance Method Details
#headers ⇒ Object
A mutable hash containing the headers for the endpoint
302 303 304 |
# File 'lib/restspec/endpoints/dsl.rb', line 302 def headers endpoint.headers end |
#method(method) ⇒ Object
Defines what the HTTP method will be.
252 253 254 |
# File 'lib/restspec/endpoints/dsl.rb', line 252 def method(method) endpoint.method = method end |
#no_schema ⇒ Object
Remove the schema of the current endpoint. Some endpoints doesn't require schemas for payload or for responses. This is the typical case for DELETE requests.
292 293 294 |
# File 'lib/restspec/endpoints/dsl.rb', line 292 def no_schema endpoint.remove_schemas end |
#path(path) ⇒ Object
Defines what the path will be. It will be append
to the namespace's base_path
and to the Restspec
config's base_url
.
266 267 268 |
# File 'lib/restspec/endpoints/dsl.rb', line 266 def path(path) endpoint.path = path end |
#schema(name, options = {}) ⇒ Object
Defines what the schema will be.
279 280 281 |
# File 'lib/restspec/endpoints/dsl.rb', line 279 def schema(name, = {}) endpoint.add_schema(name, ) end |
#url_param(param, &value_or_type_block) ⇒ Object
This set url parameters for the endpoint. It receives a key and a block returning the value. If the value is a type, an example will be generated.
321 322 323 324 325 |
# File 'lib/restspec/endpoints/dsl.rb', line 321 def url_param(param, &value_or_type_block) endpoint.add_url_param_block(param) do ExampleOrValue.new(endpoint, param, value_or_type_block).value end end |