soaspec 0.0.71 → 0.0.72

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: 5e53a58becd2e09fe58b8b40fefdd5b4b0388bea
4
- data.tar.gz: 0dd249bb58f3d9f57ae1a182bea25b2e84203db2
3
+ metadata.gz: a9bd5b574f650987fe784eaeed4d9733e40cbd03
4
+ data.tar.gz: c9ab8b52fe53aa3b8ebc3807af2a0253906eceec
5
5
  SHA512:
6
- metadata.gz: d55f91deface593e2c66a6ac06d5d0c0f9ff347f3700d9c7473a87016cb526bb5220d1a1761e41a3a99c36e5e0e7da68844844116f9a03f3bb5c6aa94d42c947
7
- data.tar.gz: 1bb1828e448a6ecbcfab0c84c7f85eec52a8c05406fccaa14e1f025fb93af701b93da348d42eae9c5a5b4cdce1cf341e729cc85990a2677e5411e5cf21b1839f
6
+ metadata.gz: a6b62377f9886cded11a729200f801c110ded422c31139c4dad350203b9404c01e4ade7e0c3a6fc9052a800ae0f2fa6341831e44e0f2a569954ad94354100de7
7
+ data.tar.gz: 24426a3ba9435bcf73c048d955be8fea9e2e23ccf0741ef442499d900ef46bb76c0b82f11fa5f8fbc9e1351e23a43efb3dfbb473b2bd8f79ed73b7667be9a179
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.0.72
2
+ * Enhancements
3
+ * Add ability to convert XML response to lower case for simpler xpath searching
4
+
1
5
  Version 0.0.71
2
6
  * Bug fix
3
7
  * Got exe 'soaspec-virtual-server' working
@@ -74,6 +74,11 @@ module Soaspec
74
74
  {}
75
75
  end
76
76
 
77
+ # @return [Boolean] Whether all xpaths will be done with XML that is converted to lower case
78
+ def convert_to_lower?
79
+ false
80
+ end
81
+
77
82
  # Stores a value in a method that can be accessed by the provided name
78
83
  # @param [Symbol] name Name of method to use to access this value within handler
79
84
  # @param [String] value Value to store
@@ -83,5 +83,14 @@ module Soaspec
83
83
  end
84
84
  end
85
85
 
86
+ # All xpath will be done with XML that is converted to lower case
87
+ # You must then use lower case in the xpath's to obtain the desired values
88
+ def convert_to_lower(set)
89
+ return unless set
90
+ define_method('convert_to_lower?') do
91
+ true
92
+ end
93
+ end
94
+
86
95
  end
87
96
  end
@@ -147,6 +147,14 @@ module Soaspec
147
147
  !body.deep_find_all(expected).empty?
148
148
  end
149
149
 
150
+ # Convert all XML nodes to lowercase
151
+ # @param [Nokogiri::XML::Document]
152
+ def convert_to_lower_case(xml_doc)
153
+ xml_doc.traverse do |node|
154
+ node.name = node.name.downcase if node.kind_of?(Nokogiri::XML::Element)
155
+ end
156
+ end
157
+
150
158
  # Returns the value at the provided xpath
151
159
  # @param [Savon::Response] response
152
160
  # @param [String] xpath
@@ -154,14 +162,14 @@ module Soaspec
154
162
  # @return [String] Value inside element found through Xpath
155
163
  def xpath_value_for(response: nil, xpath: nil, attribute: nil)
156
164
  raise ArgumentError('response and xpath must be passed to method') unless response && xpath
157
- result =
158
- if Soaspec.strip_namespaces? && !xpath.include?(':')
159
- temp_doc = response.doc.dup
160
- temp_doc.remove_namespaces!
161
- temp_doc.at_xpath(xpath)
162
- else
163
- response.xpath(xpath).first # Note this is Savon's xpath method. Hence Nokogiri 'at_xpath' not used
164
- end
165
+ temp_doc = response.doc.dup
166
+ convert_to_lower_case(temp_doc) if convert_to_lower?
167
+ result = if Soaspec.strip_namespaces? && !xpath.include?(':')
168
+ temp_doc.remove_namespaces!
169
+ temp_doc.at_xpath(xpath)
170
+ else
171
+ temp_doc.at_xpath(xpath, temp_doc.collect_namespaces)
172
+ end
165
173
  raise NoElementAtPath, "No value at Xpath '#{xpath}' in XML #{response.doc}" unless result
166
174
  return result.inner_text if attribute.nil?
167
175
  result.attributes[attribute].inner_text
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.71'.freeze
2
+ VERSION = '0.0.72'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soaspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.71
4
+ version: 0.0.72
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-30 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler