soaspec 0.0.52 → 0.0.53

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4911806fb7e9d447b98f407491c2de192f458440
4
- data.tar.gz: 4674407c680162fb21d61e0c9d2d61e27fca641f
3
+ metadata.gz: 5daa27106c98f54680acdfaf513f175a745c08cf
4
+ data.tar.gz: 2eeaffbcee9233a978c6e6abb5c94e9aa4dd6bbb
5
5
  SHA512:
6
- metadata.gz: 179745c8a33ec800887bc6d0ee6e30616a4ba348fa6f461e7e94b58a211a060cd52dfeefe7dbf0833c5270ee642b370a954af8e793467b684323e820f1855ae0
7
- data.tar.gz: 9bfbe31e1b78028e9a51470be0d43c7b5c0c31e897484bdf9ace7adac1a381f9d5964f20b08e72c6e88df101f212e649b9bd8a1c393cfb17b8cad31cc96fc39e
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soaspec (0.0.52)
4
+ soaspec (0.0.53)
5
5
  jsonpath
6
6
  rest-client (>= 2.0)
7
7
  rspec (~> 3.0)
data/Rakefile CHANGED
@@ -24,9 +24,9 @@ end
24
24
 
25
25
 
26
26
  desc 'Run tests'
27
- task :spec => %w[clean clobber use_soaspec_init logs start_test_server run_spec]
27
+ task spec: %w[clean clobber use_soaspec_init logs start_test_server run_spec]
28
28
 
29
- task :default => :spec
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') # Virtual service
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/wsdl'
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
- raise 'Unrecognised response message. Neither xml nor json detected'
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
 
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.52'.freeze
2
+ VERSION = '0.0.53'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soaspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.52
4
+ version: 0.0.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA