soaspec 0.2.4 → 0.2.5

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: 6fc08897eb83281f6c6226c6f0df1768129ec307
4
- data.tar.gz: 58e5b2672c36a667471f97159e63dea73ca44dbe
3
+ metadata.gz: 745281f9da86335fb291d91c4546429d77e5850e
4
+ data.tar.gz: dedd883ba638f9c70372bad06de044eed127f5a4
5
5
  SHA512:
6
- metadata.gz: 603ad5943c9f9e063163ab0cf485af270f0a91639a0c7a4535a9e2aeae757fac9d9ad442b14d039ece23316827e3be39ee3c53532a1cdc148d6526b37e9adc1b
7
- data.tar.gz: 03312d09ccada29afa1c5d61a8a1a559287cdd35f96289b53490f25f22d3d07e44368e14824bfdd8ef5dce579de0f4ec2d64e7a76dadc8dfc50cfdfc1bf823d0
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
@@ -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) do
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 ArgumentError("Empty Body. Can't assert on it") if response.body.empty?
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[:body]
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
@@ -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 |actual|
37
- "expected that #{actual.exchange_handler.response_body(actual.response, format: :raw)} would have element at path '#{xpath}'"
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
 
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.2.4'.freeze
2
+ VERSION = '0.2.5'.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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA