soaspec 0.2.33 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -15
  3. data/.gitlab-ci.yml +62 -62
  4. data/.rspec +3 -3
  5. data/.rubocop.yml +2 -2
  6. data/CODE_OF_CONDUCT.md +74 -74
  7. data/ChangeLog +643 -632
  8. data/Dockerfile +7 -7
  9. data/Gemfile +8 -8
  10. data/LICENSE.txt +21 -21
  11. data/README.md +253 -231
  12. data/Rakefile +52 -52
  13. data/Todo.md +16 -16
  14. data/exe/soaspec +140 -138
  15. data/exe/xml_to_yaml_file +43 -43
  16. data/lib/soaspec.rb +118 -106
  17. data/lib/soaspec/baseline.rb +82 -22
  18. data/lib/soaspec/core_ext/hash.rb +44 -44
  19. data/lib/soaspec/cucumber/generic_steps.rb +94 -94
  20. data/lib/soaspec/demo.rb +6 -6
  21. data/lib/soaspec/errors.rb +24 -24
  22. data/lib/soaspec/exchange/exchange.rb +131 -129
  23. data/lib/soaspec/exchange/exchange_extractor.rb +105 -90
  24. data/lib/soaspec/exchange/exchange_properties.rb +28 -28
  25. data/lib/soaspec/exchange/exchange_repeater.rb +21 -21
  26. data/lib/soaspec/exchange/request_builder.rb +108 -70
  27. data/lib/soaspec/exchange/variable_storer.rb +24 -24
  28. data/lib/soaspec/exchange_handlers/exchange_handler.rb +98 -98
  29. data/lib/soaspec/exchange_handlers/exchange_handler_defaults.rb +61 -61
  30. data/lib/soaspec/exchange_handlers/handler_accessors.rb +132 -132
  31. data/lib/soaspec/exchange_handlers/request/rest_request.rb +77 -59
  32. data/lib/soaspec/exchange_handlers/request/soap_request.rb +41 -41
  33. data/lib/soaspec/exchange_handlers/response_extractor.rb +84 -84
  34. data/lib/soaspec/exchange_handlers/rest_exchanger_factory.rb +111 -111
  35. data/lib/soaspec/exchange_handlers/rest_handler.rb +307 -307
  36. data/lib/soaspec/exchange_handlers/rest_methods.rb +65 -65
  37. data/lib/soaspec/exchange_handlers/rest_parameters.rb +112 -112
  38. data/lib/soaspec/exchange_handlers/rest_parameters_defaults.rb +42 -42
  39. data/lib/soaspec/exchange_handlers/soap_handler.rb +241 -241
  40. data/lib/soaspec/exe_helpers.rb +94 -94
  41. data/lib/soaspec/generate_server.rb +48 -48
  42. data/lib/soaspec/generator/.rspec.erb +5 -5
  43. data/lib/soaspec/generator/.travis.yml.erb +5 -5
  44. data/lib/soaspec/generator/Gemfile.erb +8 -8
  45. data/lib/soaspec/generator/README.md.erb +29 -29
  46. data/lib/soaspec/generator/Rakefile.erb +20 -19
  47. data/lib/soaspec/generator/config/data/default.yml.erb +2 -2
  48. data/lib/soaspec/generator/css/bootstrap.css +6833 -6833
  49. data/lib/soaspec/generator/features/support/env.rb.erb +3 -3
  50. data/lib/soaspec/generator/generate_exchange.html.erb +47 -47
  51. data/lib/soaspec/generator/lib/blz_service.rb.erb +26 -26
  52. data/lib/soaspec/generator/lib/dynamic_class_content.rb.erb +12 -12
  53. data/lib/soaspec/generator/lib/new_rest_service.rb.erb +56 -56
  54. data/lib/soaspec/generator/lib/new_soap_service.rb.erb +29 -29
  55. data/lib/soaspec/generator/lib/package_service.rb.erb +2 -2
  56. data/lib/soaspec/generator/lib/shared_example.rb.erb +8 -8
  57. data/lib/soaspec/generator/spec/dynamic_soap_spec.rb.erb +12 -12
  58. data/lib/soaspec/generator/spec/rest_spec.rb.erb +9 -9
  59. data/lib/soaspec/generator/spec/soap_spec.rb.erb +51 -51
  60. data/lib/soaspec/generator/spec/spec_helper.rb.erb +23 -23
  61. data/lib/soaspec/generator/template/soap_template.xml +6 -6
  62. data/lib/soaspec/indifferent_hash.rb +9 -9
  63. data/lib/soaspec/interpreter.rb +70 -70
  64. data/lib/soaspec/matchers.rb +136 -140
  65. data/lib/soaspec/o_auth2.rb +142 -142
  66. data/lib/soaspec/soaspec_shared_examples.rb +26 -26
  67. data/lib/soaspec/spec_logger.rb +143 -143
  68. data/lib/soaspec/template_reader.rb +30 -30
  69. data/lib/soaspec/test_server/bank.wsdl +90 -90
  70. data/lib/soaspec/test_server/get_bank.rb +166 -166
  71. data/lib/soaspec/test_server/id_manager.rb +41 -41
  72. data/lib/soaspec/test_server/invoices.rb +29 -29
  73. data/lib/soaspec/test_server/namespace.xml +14 -14
  74. data/lib/soaspec/test_server/note.xml +5 -5
  75. data/lib/soaspec/test_server/puppy_service.rb +21 -21
  76. data/lib/soaspec/test_server/test_attribute.rb +14 -14
  77. data/lib/soaspec/test_server/test_namespace.rb +14 -14
  78. data/lib/soaspec/version.rb +6 -6
  79. data/lib/soaspec/virtual_server.rb +193 -190
  80. data/lib/soaspec/wait.rb +43 -43
  81. data/lib/soaspec/wsdl_generator.rb +215 -215
  82. data/soaspec.gemspec +58 -58
  83. data/test.wsdl +116 -116
  84. data/test.xml +10 -10
  85. data/test_wsdl.rb +43 -43
  86. metadata +3 -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,59 +1,77 @@
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
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
+ # @return [Hash] Query parameters for a REST Request
44
+ def query
45
+ other_params[:q]
46
+ end
47
+
48
+ # @param [String, Symbol] value Message to send to object retrieving a value
49
+ # @return [Object] Result of retrieving value
50
+ def [](value)
51
+ send(value)
52
+ end
53
+
54
+ # @return [String] Show inspection of all parameters
55
+ def to_s
56
+ inspect
57
+ end
58
+
59
+ # @return [Array] Array containing parameters used in making a request
60
+ def flatten
61
+ [method] + [suburl].flatten + query.flatten
62
+ end
63
+
64
+ # @return [String] Description that could be used in filename
65
+ def description
66
+ suburl_desc = suburl.is_a?(Array) ? File.join(suburl) : suburl
67
+ query_desc = ''
68
+ if query
69
+ query.each do |key, value|
70
+ query_desc = File.join(query_desc, "#{key}_#{value}")
71
+ end
72
+ end
73
+ components = [method.to_s, suburl_desc, query_desc, 'response']
74
+ File.join(*components.collect!(&:to_s))
75
+ end
76
+ end
77
+ end