soaspec 0.2.4 → 0.2.5
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/lib/soaspec/exchange.rb +1 -3
- data/lib/soaspec/exchange_handlers/rest_handler.rb +4 -3
- data/lib/soaspec/matchers.rb +4 -2
- 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: 745281f9da86335fb291d91c4546429d77e5850e
|
4
|
+
data.tar.gz: dedd883ba638f9c70372bad06de044eed127f5a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bee2a56c5ceb91bdd88d0b117871f30e710bf76c1d06c10416dc761c5fab7bf5f5672369b30bd0d6490449fe8c24fc48dec79d5228c47940b51a3202f4236e21
|
7
|
+
data.tar.gz: 652a6203bbdd767967399a9141f8ac2c40b80626213c5d38e532def497bc81f0be136bb47740224c3cdffa1d8dbeb5a935cc36971b2189ea0f6883edf464d26f
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.2.5
|
2
|
+
* Bug fix
|
3
|
+
* Error wasn't throw if checking for element with empty response
|
4
|
+
* Default hash set on Exchange without example overriding value not setting request body
|
5
|
+
|
1
6
|
Version 0.2.4
|
2
7
|
* Enhancements
|
3
8
|
* Enable block to be used when creating exchange with Handler.exchange
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -187,9 +187,7 @@ class Exchange
|
|
187
187
|
if method_name[-1] == '=' # A setter method
|
188
188
|
getter_name = method_name[0..-2]
|
189
189
|
if set_value.class < Exchange # This would be prerequisite exchange
|
190
|
-
define_singleton_method(getter_name)
|
191
|
-
set_value
|
192
|
-
end
|
190
|
+
define_singleton_method(getter_name) { set_value }
|
193
191
|
self[getter_name] = set_value.id if set_value.respond_to?(:id)
|
194
192
|
else
|
195
193
|
self[getter_name] = set_value
|
@@ -196,6 +196,7 @@ module Soaspec
|
|
196
196
|
when :hash
|
197
197
|
response.dig(path.split('.')) # Use path as Hash dig expression separating params via '.' TODO: Unit test
|
198
198
|
else
|
199
|
+
raise NoElementAtPath, 'Response is empty' if response.to_s.empty?
|
199
200
|
response.to_s[/path/] # Perform regular expression using path if not XML nor JSON TODO: Unit test
|
200
201
|
end
|
201
202
|
end
|
@@ -218,7 +219,7 @@ module Soaspec
|
|
218
219
|
# @param [String] response Response as a String (either in XML or JSON)
|
219
220
|
# @return [Hash]
|
220
221
|
def extract_hash(response)
|
221
|
-
raise
|
222
|
+
raise NoElementAtPath, "Empty Body. Can't assert on it" if response.body.empty?
|
222
223
|
case Interpreter.response_type_for response
|
223
224
|
when :json
|
224
225
|
converted = JSON.parse(response.body)
|
@@ -257,7 +258,7 @@ module Soaspec
|
|
257
258
|
# Work out data to send based upon payload, template_name, or body
|
258
259
|
# @return [String] Payload to send in REST request
|
259
260
|
def post_data(test_values)
|
260
|
-
data = if @request_option == :hash && test_values[:
|
261
|
+
data = if @request_option == :hash && !test_values[:payload]
|
261
262
|
test_values[:payload] = JSON.generate(hash_used_in_request(test_values[:body])).to_s
|
262
263
|
elsif @request_option == :template
|
263
264
|
test_values = test_values[:body].dup if test_values[:body]
|
@@ -272,7 +273,7 @@ module Soaspec
|
|
272
273
|
|
273
274
|
# @return [Hash] Hash used in REST request based on data conversion
|
274
275
|
def hash_used_in_request(override_hash)
|
275
|
-
request = @default_hash.merge(override_hash)
|
276
|
+
request = override_hash ? @default_hash.merge(override_hash) : @default_hash
|
276
277
|
if pascal_keys?
|
277
278
|
request.map { |k, v| [convert_to_pascal_case(k.to_s), v] }.to_h
|
278
279
|
else
|
data/lib/soaspec/matchers.rb
CHANGED
@@ -33,8 +33,10 @@ RSpec::Matchers.define :have_element_at_path do |xpath|
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# TODO: Would be better to print failure message
|
36
|
-
failure_message do |
|
37
|
-
|
36
|
+
failure_message do |object|
|
37
|
+
# Object like `response` returns the Exchange object from which a path can be obtained
|
38
|
+
exchange = object.respond_to?(:exchange) ? object.exchange : object
|
39
|
+
"expected that #{exchange.exchange_handler.response_body(exchange.response, format: :raw)} would have element at path '#{xpath}'"
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
data/lib/soaspec/version.rb
CHANGED