soaspec 0.2.32 → 0.2.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -15
- data/.gitlab-ci.yml +62 -62
- data/.rspec +3 -3
- data/.rubocop.yml +2 -2
- data/CODE_OF_CONDUCT.md +74 -74
- data/ChangeLog +632 -625
- data/Dockerfile +7 -7
- data/Gemfile +8 -8
- data/LICENSE.txt +21 -21
- data/README.md +231 -231
- data/Rakefile +52 -52
- data/Todo.md +16 -16
- data/exe/soaspec +138 -138
- data/exe/xml_to_yaml_file +43 -43
- data/lib/soaspec.rb +106 -105
- data/lib/soaspec/baseline.rb +23 -0
- data/lib/soaspec/core_ext/hash.rb +44 -44
- data/lib/soaspec/cucumber/generic_steps.rb +94 -94
- data/lib/soaspec/demo.rb +6 -6
- data/lib/soaspec/errors.rb +24 -22
- data/lib/soaspec/exchange/exchange.rb +129 -129
- data/lib/soaspec/exchange/exchange_extractor.rb +90 -90
- data/lib/soaspec/exchange/exchange_properties.rb +28 -28
- data/lib/soaspec/exchange/exchange_repeater.rb +21 -21
- data/lib/soaspec/exchange/request_builder.rb +70 -70
- data/lib/soaspec/exchange/variable_storer.rb +24 -24
- data/lib/soaspec/exchange_handlers/exchange_handler.rb +98 -98
- data/lib/soaspec/exchange_handlers/exchange_handler_defaults.rb +61 -61
- data/lib/soaspec/exchange_handlers/handler_accessors.rb +132 -132
- data/lib/soaspec/exchange_handlers/request/rest_request.rb +59 -51
- data/lib/soaspec/exchange_handlers/request/soap_request.rb +41 -41
- data/lib/soaspec/exchange_handlers/response_extractor.rb +84 -84
- data/lib/soaspec/exchange_handlers/rest_exchanger_factory.rb +111 -111
- data/lib/soaspec/exchange_handlers/rest_handler.rb +307 -298
- data/lib/soaspec/exchange_handlers/rest_methods.rb +65 -65
- data/lib/soaspec/exchange_handlers/rest_parameters.rb +112 -112
- data/lib/soaspec/exchange_handlers/rest_parameters_defaults.rb +42 -42
- data/lib/soaspec/exchange_handlers/soap_handler.rb +241 -241
- data/lib/soaspec/exe_helpers.rb +94 -94
- data/lib/soaspec/generate_server.rb +48 -48
- data/lib/soaspec/generator/.rspec.erb +5 -5
- data/lib/soaspec/generator/.travis.yml.erb +5 -5
- data/lib/soaspec/generator/Gemfile.erb +8 -8
- data/lib/soaspec/generator/README.md.erb +29 -29
- data/lib/soaspec/generator/Rakefile.erb +19 -19
- data/lib/soaspec/generator/config/data/default.yml.erb +2 -2
- data/lib/soaspec/generator/css/bootstrap.css +6833 -6833
- data/lib/soaspec/generator/features/support/env.rb.erb +3 -3
- data/lib/soaspec/generator/generate_exchange.html.erb +47 -47
- data/lib/soaspec/generator/lib/blz_service.rb.erb +26 -26
- data/lib/soaspec/generator/lib/dynamic_class_content.rb.erb +12 -12
- data/lib/soaspec/generator/lib/new_rest_service.rb.erb +56 -56
- data/lib/soaspec/generator/lib/new_soap_service.rb.erb +29 -29
- data/lib/soaspec/generator/lib/package_service.rb.erb +2 -2
- data/lib/soaspec/generator/lib/shared_example.rb.erb +8 -8
- data/lib/soaspec/generator/spec/dynamic_soap_spec.rb.erb +12 -12
- data/lib/soaspec/generator/spec/rest_spec.rb.erb +9 -9
- data/lib/soaspec/generator/spec/soap_spec.rb.erb +51 -51
- data/lib/soaspec/generator/spec/spec_helper.rb.erb +23 -23
- data/lib/soaspec/generator/template/soap_template.xml +6 -6
- data/lib/soaspec/indifferent_hash.rb +9 -9
- data/lib/soaspec/interpreter.rb +70 -70
- data/lib/soaspec/matchers.rb +140 -118
- data/lib/soaspec/o_auth2.rb +142 -142
- data/lib/soaspec/soaspec_shared_examples.rb +26 -26
- data/lib/soaspec/spec_logger.rb +143 -143
- data/lib/soaspec/template_reader.rb +30 -30
- data/lib/soaspec/test_server/bank.wsdl +90 -90
- data/lib/soaspec/test_server/get_bank.rb +166 -166
- data/lib/soaspec/test_server/id_manager.rb +41 -41
- data/lib/soaspec/test_server/invoices.rb +29 -29
- data/lib/soaspec/test_server/namespace.xml +14 -14
- data/lib/soaspec/test_server/note.xml +5 -5
- data/lib/soaspec/test_server/puppy_service.rb +21 -21
- data/lib/soaspec/test_server/test_attribute.rb +14 -14
- data/lib/soaspec/test_server/test_namespace.rb +14 -14
- data/lib/soaspec/version.rb +6 -6
- data/lib/soaspec/virtual_server.rb +190 -176
- data/lib/soaspec/wait.rb +43 -43
- data/lib/soaspec/wsdl_generator.rb +215 -215
- data/soaspec.gemspec +58 -58
- data/test.wsdl +116 -116
- data/test.xml +10 -10
- data/test_wsdl.rb +43 -43
- metadata +4 -3
@@ -1,61 +1,61 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Default values set for methods on ExchangeHandler
|
4
|
-
module ExchangeHandlerDefaults
|
5
|
-
# Will be used in 'success_scenarios' shared examples.
|
6
|
-
# Set though 'mandatory_elements' method
|
7
|
-
# @return [Array] Array of symbols specifying element names
|
8
|
-
def expected_mandatory_elements
|
9
|
-
[]
|
10
|
-
end
|
11
|
-
|
12
|
-
# Change this through 'mandatory_xpath_values' method to specify xpath results that must be present in the response
|
13
|
-
# Will be used in 'success_scenarios' shared examples
|
14
|
-
# @return [Hash] Hash of 'xpath' => 'expected value' pairs
|
15
|
-
def expected_mandatory_xpath_values
|
16
|
-
{}
|
17
|
-
end
|
18
|
-
|
19
|
-
# Change this through 'mandatory_json_values' method to specify json results that must be present in the response
|
20
|
-
# Will be used in 'success_scenarios' shared examples
|
21
|
-
# @return [Hash] Hash of 'json/path' => 'expected value' pairs
|
22
|
-
def expected_mandatory_json_values
|
23
|
-
{}
|
24
|
-
end
|
25
|
-
|
26
|
-
# @return [Boolean] Whether all xpaths will be done with XML that is converted to lower case
|
27
|
-
def convert_to_lower?
|
28
|
-
false
|
29
|
-
end
|
30
|
-
|
31
|
-
# @return [Boolean] Whether to remove namespaces in xpath assertion automatically
|
32
|
-
def strip_namespaces?
|
33
|
-
false
|
34
|
-
end
|
35
|
-
|
36
|
-
# Request of API call. Either intended request or actual request
|
37
|
-
# @param [Object] response Response from calling exchange
|
38
|
-
def request(response)
|
39
|
-
return "Request not yet sent Request option is #{@request_option}" unless response
|
40
|
-
|
41
|
-
'Specific API handler should implement this'
|
42
|
-
end
|
43
|
-
|
44
|
-
# Set through 'retry_on_exceptions' method
|
45
|
-
# @return [Array] List of exceptions to retry for
|
46
|
-
def retry_on_exceptions
|
47
|
-
[]
|
48
|
-
end
|
49
|
-
|
50
|
-
# Set this through 'retry_on_exceptions' on ExchangeHandler
|
51
|
-
# @return [Integer] Time to wait before retrying each request. Default of 1
|
52
|
-
def retry_pause_time
|
53
|
-
1
|
54
|
-
end
|
55
|
-
|
56
|
-
# Set this through 'retry_on_exceptions' on ExchangeHandler
|
57
|
-
# @return [Integer] Times to retry before raising exception. Default of 3
|
58
|
-
def retry_exception_limit
|
59
|
-
3
|
60
|
-
end
|
61
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Default values set for methods on ExchangeHandler
|
4
|
+
module ExchangeHandlerDefaults
|
5
|
+
# Will be used in 'success_scenarios' shared examples.
|
6
|
+
# Set though 'mandatory_elements' method
|
7
|
+
# @return [Array] Array of symbols specifying element names
|
8
|
+
def expected_mandatory_elements
|
9
|
+
[]
|
10
|
+
end
|
11
|
+
|
12
|
+
# Change this through 'mandatory_xpath_values' method to specify xpath results that must be present in the response
|
13
|
+
# Will be used in 'success_scenarios' shared examples
|
14
|
+
# @return [Hash] Hash of 'xpath' => 'expected value' pairs
|
15
|
+
def expected_mandatory_xpath_values
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Change this through 'mandatory_json_values' method to specify json results that must be present in the response
|
20
|
+
# Will be used in 'success_scenarios' shared examples
|
21
|
+
# @return [Hash] Hash of 'json/path' => 'expected value' pairs
|
22
|
+
def expected_mandatory_json_values
|
23
|
+
{}
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Boolean] Whether all xpaths will be done with XML that is converted to lower case
|
27
|
+
def convert_to_lower?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Boolean] Whether to remove namespaces in xpath assertion automatically
|
32
|
+
def strip_namespaces?
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
# Request of API call. Either intended request or actual request
|
37
|
+
# @param [Object] response Response from calling exchange
|
38
|
+
def request(response)
|
39
|
+
return "Request not yet sent Request option is #{@request_option}" unless response
|
40
|
+
|
41
|
+
'Specific API handler should implement this'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Set through 'retry_on_exceptions' method
|
45
|
+
# @return [Array] List of exceptions to retry for
|
46
|
+
def retry_on_exceptions
|
47
|
+
[]
|
48
|
+
end
|
49
|
+
|
50
|
+
# Set this through 'retry_on_exceptions' on ExchangeHandler
|
51
|
+
# @return [Integer] Time to wait before retrying each request. Default of 1
|
52
|
+
def retry_pause_time
|
53
|
+
1
|
54
|
+
end
|
55
|
+
|
56
|
+
# Set this through 'retry_on_exceptions' on ExchangeHandler
|
57
|
+
# @return [Integer] Times to retry before raising exception. Default of 3
|
58
|
+
def retry_exception_limit
|
59
|
+
3
|
60
|
+
end
|
61
|
+
end
|
@@ -1,132 +1,132 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Soaspec
|
4
|
-
# Describes methods test handlers use to easily set attributes
|
5
|
-
# Some are included in 'success scenarios' and to configure the request sent
|
6
|
-
module HandlerAccessors
|
7
|
-
# Defines expected_mandatory_elements method used in 'success_scenario' shared examples
|
8
|
-
# to indicate certain elements must be present
|
9
|
-
# @param [Array] elements Array of symbols specifying expected element names for 'success scenario' in snakecase
|
10
|
-
#
|
11
|
-
# @example Inside class
|
12
|
-
# mandatory_elements :GetWeatherResult
|
13
|
-
#
|
14
|
-
# Or for a list
|
15
|
-
#
|
16
|
-
# @example Inside class
|
17
|
-
# mandatory_elements [:GetWeatherResult, :GetResultStatus]
|
18
|
-
#
|
19
|
-
# In test
|
20
|
-
# describe Exchange(:name) do
|
21
|
-
# it_behaves_like 'success scenario' # Includes checks for mandatory elements
|
22
|
-
# end
|
23
|
-
def mandatory_elements(elements)
|
24
|
-
define_method('expected_mandatory_elements') do
|
25
|
-
return [elements] if elements.is_a?(String) || elements.is_a?(Symbol)
|
26
|
-
|
27
|
-
elements
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Defines mandatory xpaths value pairs to be included in 'success scenario' shared example
|
32
|
-
#
|
33
|
-
# @example Inside class
|
34
|
-
# mandatory_xpath_values '//xmlns:GetWeatherResult' => 'Data Not Found'
|
35
|
-
#
|
36
|
-
# @example In test
|
37
|
-
# describe Exchange(:name) do
|
38
|
-
# it_behaves_like 'success scenario' # Includes xpath pair validation
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# @param [Hash] xpath_value_pairs Hash of element => expected value that must appear
|
42
|
-
# in a successful response body
|
43
|
-
def mandatory_xpath_values(xpath_value_pairs)
|
44
|
-
raise ArgumentError('Hash of {xpath => expected values} expected ') unless xpath_value_pairs.is_a? Hash
|
45
|
-
|
46
|
-
define_method('expected_mandatory_xpath_values') { xpath_value_pairs }
|
47
|
-
end
|
48
|
-
|
49
|
-
# Defines mandatory json path value pairs to be included in 'success scenario' shared example
|
50
|
-
#
|
51
|
-
# @example Inside class
|
52
|
-
# mandatory_json_values '$..GetWeatherResult' => 'Found'
|
53
|
-
#
|
54
|
-
# @example In test
|
55
|
-
# describe Exchange(:name) do
|
56
|
-
# it_behaves_like 'success scenario' # Includes json pair validation
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# @param [Hash] json_value_pairs Hash of element => expected value that must appear
|
60
|
-
# in a successful response body
|
61
|
-
def mandatory_json_values(json_value_pairs)
|
62
|
-
raise ArgumentError("Hash of {'jsonpath' => expected values} expected") unless json_value_pairs.is_a? Hash
|
63
|
-
|
64
|
-
define_method('expected_mandatory_json_values') { json_value_pairs }
|
65
|
-
end
|
66
|
-
|
67
|
-
# Links a particular path to a meaningful method that can be accessed from Exchange class.
|
68
|
-
# This will use the 'value_from_path' method which
|
69
|
-
# should be implemented by each ExchangeHandler
|
70
|
-
# @param [String, Symbol] name Method name used to access element
|
71
|
-
# @param [String, Symbol] path Path to find object (e.g, XPath, JSONPath).
|
72
|
-
# For JSONPath a ',' can be put to get an element either path
|
73
|
-
def element(name, path)
|
74
|
-
define_method("__custom_path_#{name}") do |response|
|
75
|
-
value_from_path(response, path.to_s)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Links an attribute to a meaningful method that can be accessed from Exchange class.
|
80
|
-
# This will use the 'value_from_path' method which
|
81
|
-
# should be implemented by each ExchangeHandler
|
82
|
-
# @param [String, Symbol] name Method name used to access attribute
|
83
|
-
# @param [String, nil, Hash] attribute Attribute name to extract from xml. If not set, this will default to @name
|
84
|
-
def attribute(name, attribute = nil)
|
85
|
-
attribute_used = attribute || name.to_s
|
86
|
-
define_method("__custom_path_#{name}") do |response|
|
87
|
-
value_from_path(response, 'implicit', attribute: attribute_used)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# All xpath will be done with XML that is converted to lower case
|
92
|
-
# You must then use lower case in the xpath's to obtain the desired values
|
93
|
-
# @param [Boolean] set Whether to convert all xml in response to lower case before performing XPath
|
94
|
-
def convert_to_lower(set)
|
95
|
-
return unless set
|
96
|
-
|
97
|
-
define_method('convert_to_lower?') { true }
|
98
|
-
end
|
99
|
-
|
100
|
-
# Whether to remove namespaces from response in Xpath assertion automatically
|
101
|
-
# For why this may not be a good thing in general see
|
102
|
-
# http://tenderlovemaking.com/2009/04/23/namespaces-in-xml.html
|
103
|
-
# This will be overridden if xpath has a ':' in it
|
104
|
-
# @param [Boolean] set Whether to strip namespaces form XML response
|
105
|
-
def strip_namespaces(set)
|
106
|
-
return unless set
|
107
|
-
|
108
|
-
# Whether to remove namespaces in xpath assertion automatically
|
109
|
-
define_method('strip_namespaces?') { true }
|
110
|
-
end
|
111
|
-
|
112
|
-
# Set the default hash representing data to be used in making a request
|
113
|
-
# This will set the @request_option instance variable too
|
114
|
-
# @param [Hash] hash Default hash of request
|
115
|
-
def default_hash(hash)
|
116
|
-
define_method('default_hash_value') do
|
117
|
-
@request_option = :hash
|
118
|
-
Soaspec.always_use_keys? ? hash.transform_keys_to_symbols : hash
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# Set the request option type and the template name
|
123
|
-
# Erb is used to parse the template file, executing Ruby code in `<%= %>` blocks to work out the final request
|
124
|
-
# @param [String] name Name of file inside 'template' folder excluding extension
|
125
|
-
def template_name(name)
|
126
|
-
define_method('template_name_value') do
|
127
|
-
@request_option = :template
|
128
|
-
name
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Soaspec
|
4
|
+
# Describes methods test handlers use to easily set attributes
|
5
|
+
# Some are included in 'success scenarios' and to configure the request sent
|
6
|
+
module HandlerAccessors
|
7
|
+
# Defines expected_mandatory_elements method used in 'success_scenario' shared examples
|
8
|
+
# to indicate certain elements must be present
|
9
|
+
# @param [Array] elements Array of symbols specifying expected element names for 'success scenario' in snakecase
|
10
|
+
#
|
11
|
+
# @example Inside class
|
12
|
+
# mandatory_elements :GetWeatherResult
|
13
|
+
#
|
14
|
+
# Or for a list
|
15
|
+
#
|
16
|
+
# @example Inside class
|
17
|
+
# mandatory_elements [:GetWeatherResult, :GetResultStatus]
|
18
|
+
#
|
19
|
+
# In test
|
20
|
+
# describe Exchange(:name) do
|
21
|
+
# it_behaves_like 'success scenario' # Includes checks for mandatory elements
|
22
|
+
# end
|
23
|
+
def mandatory_elements(elements)
|
24
|
+
define_method('expected_mandatory_elements') do
|
25
|
+
return [elements] if elements.is_a?(String) || elements.is_a?(Symbol)
|
26
|
+
|
27
|
+
elements
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Defines mandatory xpaths value pairs to be included in 'success scenario' shared example
|
32
|
+
#
|
33
|
+
# @example Inside class
|
34
|
+
# mandatory_xpath_values '//xmlns:GetWeatherResult' => 'Data Not Found'
|
35
|
+
#
|
36
|
+
# @example In test
|
37
|
+
# describe Exchange(:name) do
|
38
|
+
# it_behaves_like 'success scenario' # Includes xpath pair validation
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# @param [Hash] xpath_value_pairs Hash of element => expected value that must appear
|
42
|
+
# in a successful response body
|
43
|
+
def mandatory_xpath_values(xpath_value_pairs)
|
44
|
+
raise ArgumentError('Hash of {xpath => expected values} expected ') unless xpath_value_pairs.is_a? Hash
|
45
|
+
|
46
|
+
define_method('expected_mandatory_xpath_values') { xpath_value_pairs }
|
47
|
+
end
|
48
|
+
|
49
|
+
# Defines mandatory json path value pairs to be included in 'success scenario' shared example
|
50
|
+
#
|
51
|
+
# @example Inside class
|
52
|
+
# mandatory_json_values '$..GetWeatherResult' => 'Found'
|
53
|
+
#
|
54
|
+
# @example In test
|
55
|
+
# describe Exchange(:name) do
|
56
|
+
# it_behaves_like 'success scenario' # Includes json pair validation
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# @param [Hash] json_value_pairs Hash of element => expected value that must appear
|
60
|
+
# in a successful response body
|
61
|
+
def mandatory_json_values(json_value_pairs)
|
62
|
+
raise ArgumentError("Hash of {'jsonpath' => expected values} expected") unless json_value_pairs.is_a? Hash
|
63
|
+
|
64
|
+
define_method('expected_mandatory_json_values') { json_value_pairs }
|
65
|
+
end
|
66
|
+
|
67
|
+
# Links a particular path to a meaningful method that can be accessed from Exchange class.
|
68
|
+
# This will use the 'value_from_path' method which
|
69
|
+
# should be implemented by each ExchangeHandler
|
70
|
+
# @param [String, Symbol] name Method name used to access element
|
71
|
+
# @param [String, Symbol] path Path to find object (e.g, XPath, JSONPath).
|
72
|
+
# For JSONPath a ',' can be put to get an element either path
|
73
|
+
def element(name, path)
|
74
|
+
define_method("__custom_path_#{name}") do |response|
|
75
|
+
value_from_path(response, path.to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Links an attribute to a meaningful method that can be accessed from Exchange class.
|
80
|
+
# This will use the 'value_from_path' method which
|
81
|
+
# should be implemented by each ExchangeHandler
|
82
|
+
# @param [String, Symbol] name Method name used to access attribute
|
83
|
+
# @param [String, nil, Hash] attribute Attribute name to extract from xml. If not set, this will default to @name
|
84
|
+
def attribute(name, attribute = nil)
|
85
|
+
attribute_used = attribute || name.to_s
|
86
|
+
define_method("__custom_path_#{name}") do |response|
|
87
|
+
value_from_path(response, 'implicit', attribute: attribute_used)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# All xpath will be done with XML that is converted to lower case
|
92
|
+
# You must then use lower case in the xpath's to obtain the desired values
|
93
|
+
# @param [Boolean] set Whether to convert all xml in response to lower case before performing XPath
|
94
|
+
def convert_to_lower(set)
|
95
|
+
return unless set
|
96
|
+
|
97
|
+
define_method('convert_to_lower?') { true }
|
98
|
+
end
|
99
|
+
|
100
|
+
# Whether to remove namespaces from response in Xpath assertion automatically
|
101
|
+
# For why this may not be a good thing in general see
|
102
|
+
# http://tenderlovemaking.com/2009/04/23/namespaces-in-xml.html
|
103
|
+
# This will be overridden if xpath has a ':' in it
|
104
|
+
# @param [Boolean] set Whether to strip namespaces form XML response
|
105
|
+
def strip_namespaces(set)
|
106
|
+
return unless set
|
107
|
+
|
108
|
+
# Whether to remove namespaces in xpath assertion automatically
|
109
|
+
define_method('strip_namespaces?') { true }
|
110
|
+
end
|
111
|
+
|
112
|
+
# Set the default hash representing data to be used in making a request
|
113
|
+
# This will set the @request_option instance variable too
|
114
|
+
# @param [Hash] hash Default hash of request
|
115
|
+
def default_hash(hash)
|
116
|
+
define_method('default_hash_value') do
|
117
|
+
@request_option = :hash
|
118
|
+
Soaspec.always_use_keys? ? hash.transform_keys_to_symbols : hash
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Set the request option type and the template name
|
123
|
+
# Erb is used to parse the template file, executing Ruby code in `<%= %>` blocks to work out the final request
|
124
|
+
# @param [String] name Name of file inside 'template' folder excluding extension
|
125
|
+
def template_name(name)
|
126
|
+
define_method('template_name_value') do
|
127
|
+
@request_option = :template
|
128
|
+
name
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -1,51 +1,59 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Soaspec
|
4
|
-
# Models a request made to a REST API
|
5
|
-
class RestRequest
|
6
|
-
# @example GET method
|
7
|
-
# :get
|
8
|
-
# @return [Symbol] REST method used
|
9
|
-
attr_accessor :method
|
10
|
-
# @example JSON body
|
11
|
-
# {"test":5}
|
12
|
-
# @return [String] Body of request sent
|
13
|
-
attr_accessor :body
|
14
|
-
# @return [String] Name given to test to describe it
|
15
|
-
attr_accessor :test_name
|
16
|
-
# @return [String] User used in basic auth
|
17
|
-
attr_accessor :basic_auth_user
|
18
|
-
# @return [String] Password used in basic auth
|
19
|
-
attr_accessor :basic_auth_password
|
20
|
-
# @return [String] Url appended to base_url
|
21
|
-
attr_accessor :suburl
|
22
|
-
# @return [Hash] Miscellaneous parameters
|
23
|
-
attr_accessor :other_params
|
24
|
-
# Headers. Keys that are `symbols` will be converted from `snake_case` to `Word-Word2`
|
25
|
-
# @return [Hash] Headers sent as part of request
|
26
|
-
attr_accessor :headers
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
self.
|
34
|
-
self.
|
35
|
-
self.
|
36
|
-
self.
|
37
|
-
self.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Soaspec
|
4
|
+
# Models a request made to a REST API
|
5
|
+
class RestRequest
|
6
|
+
# @example GET method
|
7
|
+
# :get
|
8
|
+
# @return [Symbol] REST method used
|
9
|
+
attr_accessor :method
|
10
|
+
# @example JSON body
|
11
|
+
# {"test":5}
|
12
|
+
# @return [String] Body of request sent
|
13
|
+
attr_accessor :body
|
14
|
+
# @return [String] Name given to test to describe it
|
15
|
+
attr_accessor :test_name
|
16
|
+
# @return [String] User used in basic auth
|
17
|
+
attr_accessor :basic_auth_user
|
18
|
+
# @return [String] Password used in basic auth
|
19
|
+
attr_accessor :basic_auth_password
|
20
|
+
# @return [String] Url appended to base_url
|
21
|
+
attr_accessor :suburl
|
22
|
+
# @return [Hash] Miscellaneous parameters
|
23
|
+
attr_accessor :other_params
|
24
|
+
# Headers. Keys that are `symbols` will be converted from `snake_case` to `Word-Word2`
|
25
|
+
# @return [Hash] Headers sent as part of request
|
26
|
+
attr_accessor :headers
|
27
|
+
|
28
|
+
# @param [Hash] overall Overall parameters used in Request
|
29
|
+
# @param [Hash] options Headers and basic auth options
|
30
|
+
# @param [String] body Body of Request to be sent
|
31
|
+
def initialize(overall, options, body)
|
32
|
+
overall_params = overall.dup # Must duplicate hash as deletion occurring
|
33
|
+
self.body = body
|
34
|
+
self.method = overall_params.delete(:method)
|
35
|
+
self.suburl = overall_params.delete(:suburl)
|
36
|
+
self.test_name = overall_params.delete(:name)
|
37
|
+
self.other_params = overall_params
|
38
|
+
self.basic_auth_user = options[:user]
|
39
|
+
self.basic_auth_password = options[:password]
|
40
|
+
self.headers = options[:headers]
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [String, Symbol] value Message to send to object retrieving a value
|
44
|
+
# @return [Object] Result of retrieving value
|
45
|
+
def [](value)
|
46
|
+
send(value)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [String] Show inspection of all parameters
|
50
|
+
def to_s
|
51
|
+
inspect
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [Array] Array containing parameters used in making a request
|
55
|
+
def flatten
|
56
|
+
[method] + [suburl].flatten + other_params[:q].flatten
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|