Class: Exchange
- Inherits:
-
Object
- Object
- Exchange
- Defined in:
- lib/soaspec/exchange.rb
Overview
This represents a request / response pair
Instance Method Summary collapse
-
#[](path) ⇒ String
Extract value from path api class.
-
#initialize(name, override_parameters = {}) ⇒ Exchange
constructor
A new instance of Exchange.
-
#make_request ⇒ Object
Make request to handler with parameters defined.
-
#mandatory_elements ⇒ Object
Elements a shared ‘success scenario’ is expected to have.
-
#mandatory_xpath_values ⇒ Object
Elements a shared ‘success scenario’ is expected to have.
-
#response ⇒ Object
Returns response object from Api For example for SOAP it will be a Savon response response.body (body of response as Hash) response.header (head of response as Hash).
-
#status_code ⇒ Integer
Get status code from api class.
-
#to_s ⇒ String
Name describing this class when used with
RSpec.describeThis will make the request and store the response.
Constructor Details
#initialize(name, override_parameters = {}) ⇒ Exchange
Returns a new instance of Exchange.
6 7 8 9 10 |
# File 'lib/soaspec/exchange.rb', line 6 def initialize(name, override_parameters = {}) @test_name = name.to_s @api_class = Soaspec::Environment.api_handler @override_parameters = override_parameters end |
Instance Method Details
#[](path) ⇒ String
Extract value from path api class
53 54 55 |
# File 'lib/soaspec/exchange.rb', line 53 def [](path) @api_class.value_from_path(self, path) end |
#make_request ⇒ Object
Make request to handler with parameters defined
13 14 15 |
# File 'lib/soaspec/exchange.rb', line 13 def make_request @api_class.make_request(@override_parameters) end |
#mandatory_elements ⇒ Object
Elements a shared ‘success scenario’ is expected to have
27 28 29 |
# File 'lib/soaspec/exchange.rb', line 27 def mandatory_elements @api_class.mandatory_elements end |
#mandatory_xpath_values ⇒ Object
Elements a shared ‘success scenario’ is expected to have
32 33 34 |
# File 'lib/soaspec/exchange.rb', line 32 def mandatory_xpath_values @api_class.mandatory_xpath_values end |
#response ⇒ Object
Returns response object from Api For example for SOAP it will be a Savon response response.body (body of response as Hash) response.header (head of response as Hash)
40 41 42 |
# File 'lib/soaspec/exchange.rb', line 40 def response @response end |
#status_code ⇒ Integer
Get status code from api class. This is http response for Web Api
46 47 48 |
# File 'lib/soaspec/exchange.rb', line 46 def status_code @api_class.status_code_for(@response) end |
#to_s ⇒ String
Name describing this class when used with RSpec.describe This will make the request and store the response
20 21 22 23 24 |
# File 'lib/soaspec/exchange.rb', line 20 def to_s Soaspec::SpecLogger.add_to 'Example ' + @test_name @response = make_request @test_name end |