soaspec 0.0.52 → 0.0.53
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.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -2
- data/exe/soaspec-init +4 -3
- data/lib/soaspec/exchange_handlers/rest_handler.rb +12 -5
- data/lib/soaspec/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5daa27106c98f54680acdfaf513f175a745c08cf
|
4
|
+
data.tar.gz: 2eeaffbcee9233a978c6e6abb5c94e9aa4dd6bbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7014f7f8944d4ffb28ee0391800d7167544236c4e0be5827e8954ff41c0b8fd882e10ee87670a91807282927c8d266584f34e3309db6f453ccf7366c2622e30a
|
7
|
+
data.tar.gz: dfb370de19a9640736b5e1f2bd365d1c8206f548b557625c62f75c4b2f023435b728c89fde95cfe414ac43d8486ef19973756d5006ec32ea2fa63d8b27cf2f4f
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.53
|
2
|
+
* Enhancements
|
3
|
+
* Make attribute possible for REST methods as well (as they can use XML too)
|
4
|
+
* For non XML, non JSON responses, handle with regex or key for a Hash
|
5
|
+
|
1
6
|
Version 0.0.52
|
2
7
|
* Enhancements
|
3
8
|
* Now have 'attribute' accessor making it easy to access an attribute from a response
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -24,9 +24,9 @@ end
|
|
24
24
|
|
25
25
|
|
26
26
|
desc 'Run tests'
|
27
|
-
task :
|
27
|
+
task spec: %w[clean clobber use_soaspec_init logs start_test_server run_spec]
|
28
28
|
|
29
|
-
task :
|
29
|
+
task default: :spec
|
30
30
|
|
31
31
|
CLEAN.include 'tmp/*'
|
32
32
|
CLOBBER.include 'logs/*'
|
data/exe/soaspec-init
CHANGED
@@ -21,7 +21,7 @@ class BLZService < Soaspec::SoapHandler
|
|
21
21
|
def savon_options
|
22
22
|
{
|
23
23
|
# wsdl: 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl' # External
|
24
|
-
wsdl: File.join('spec', 'wsdl', 'get_bank.wsdl')
|
24
|
+
wsdl: File.join('spec', 'test_data', 'wsdl', 'get_bank.wsdl')
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
@@ -228,11 +228,12 @@ create_folder 'config'
|
|
228
228
|
create_folder 'config/data'
|
229
229
|
create_file(filename: 'config/data/default.yml', content: default_yaml_content)
|
230
230
|
create_folder 'spec'
|
231
|
-
create_folder 'spec/
|
231
|
+
create_folder 'spec/test_data'
|
232
|
+
create_folder 'spec/test_data/wsdl'
|
232
233
|
create_file(filename: 'spec/spec_helper.rb', content: spec_helper_content)
|
233
234
|
create_file(filename: 'spec/soap_spec.rb', content: soap_spec_content)
|
234
235
|
create_file(filename: 'spec/test_server.rb', content: test_server_content)
|
235
|
-
create_file(filename: 'spec/wsdl/get_bank.wsdl', content: test_wsdl_content)
|
236
|
+
create_file(filename: 'spec/test_data/wsdl/get_bank.wsdl', content: test_wsdl_content)
|
236
237
|
create_folder 'template'
|
237
238
|
create_file(filename: 'template/soap_template.xml', content: soap_template_content)
|
238
239
|
create_folder 'logs'
|
@@ -228,7 +228,7 @@ module Soaspec
|
|
228
228
|
# @param [RestClient::Response] response
|
229
229
|
# @param [String] xpath
|
230
230
|
# @return [String] Value inside element found through Xpath
|
231
|
-
def xpath_value_for(response: nil, xpath: nil)
|
231
|
+
def xpath_value_for(response: nil, xpath: nil, attribute: nil)
|
232
232
|
raise ArgumentError unless response && xpath
|
233
233
|
raise "Can't perform XPATH if response is not XML" unless Interpreter.response_type_for(response) == :xml
|
234
234
|
result =
|
@@ -240,27 +240,34 @@ module Soaspec
|
|
240
240
|
Nokogiri.parse(response.body).xpath(xpath).first
|
241
241
|
end
|
242
242
|
raise NoElementAtPath, "No value at Xpath '#{xpath}'" unless result
|
243
|
-
result.inner_text
|
243
|
+
return result.inner_text if attribute.nil?
|
244
|
+
result.attributes[attribute].inner_text
|
244
245
|
end
|
245
246
|
|
246
247
|
# Based on a exchange, return the value at the provided xpath
|
247
248
|
# If the path does not begin with a '/', a '//' is added to it
|
248
249
|
# @param [Response] response
|
249
250
|
# @param [Object] path Xpath, JSONPath or other path identifying how to find element
|
251
|
+
# @param [String] attribute Generic attribute to find. Will override path
|
250
252
|
# @return [String] Value at Xpath
|
251
|
-
def value_from_path(response, path)
|
253
|
+
def value_from_path(response, path, attribute: nil)
|
252
254
|
path = path.to_s
|
255
|
+
|
253
256
|
case Interpreter.response_type_for(response)
|
254
257
|
when :xml
|
258
|
+
path = "//*[@#{attribute}]" unless attribute.nil?
|
255
259
|
path = '//' + path if path[0] != '/'
|
256
|
-
xpath_value_for(response: response, xpath: path)
|
260
|
+
xpath_value_for(response: response, xpath: path, attribute: attribute)
|
257
261
|
when :json
|
262
|
+
raise 'JSON does not support attributes' if attribute
|
258
263
|
path = '$..' + path if path[0] != '$'
|
259
264
|
matching_values = JsonPath.on(response.body, path)
|
260
265
|
raise NoElementAtPath, "Element in #{response.body} not found with path '#{path}'" if matching_values.empty?
|
261
266
|
matching_values.first
|
267
|
+
when :hash
|
268
|
+
response.dig(path.split('.')) # Use path as Hash dig expression separating params via '.' TODO: Unit test
|
262
269
|
else
|
263
|
-
|
270
|
+
response.to_s[/path/] # Perform regular expression using path if not XML nor JSON TODO: Unit test
|
264
271
|
end
|
265
272
|
end
|
266
273
|
|
data/lib/soaspec/version.rb
CHANGED