soaspec 0.0.63 → 0.0.64

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: bbd6200218cc74c240264b8f39b0061fb196d175
4
- data.tar.gz: cbdde5a4d6771a6d91ef00101b27b92de0c35d59
3
+ metadata.gz: 25c86df1d3a144dc27e77be77a31c9b4391fd07a
4
+ data.tar.gz: 9fae1931ca918a24b6d44e7a7539225d79d829ee
5
5
  SHA512:
6
- metadata.gz: 37ab895847c2dd195a646aa19afbacc1135f39bcb3a6062948d7bd09a2a8368291bb0fd27decc027eabfd97653403a58a86233b68fa4990cbc7affd0de445d27
7
- data.tar.gz: d7cb6508f82c1f4c9c0de7149df0c95c4170347fd73a634fb48d760aa39e812ba29978c2b5790b25912ac80a0c569ea0b45968d5807ae3d38a1d8df023e316bf
6
+ metadata.gz: 2f876e1f3e3e532e9c4dd0bc65cc16e50da035d165a9d712add298c4221a61cd3808c9f13a779658543d22c2339060af88ee4bedb01b01df93a44e1982c1b665
7
+ data.tar.gz: 9e913c8ded49a9df53a65ae78a9e3672e725486f755c562ea3610e092a301ce773e8a217143e0cda0d21dc7e498a0236e5cc5e72355ead42853130f6b111c1e1
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Version 0.0.64
2
+ * Enhancements
3
+ * Got FactoryBot working for RestHandler. See specs for example
4
+ * Add element? method to exchange to make it easier to check element is at path
5
+ * Define 'element_name?' created when element is defined on ExchangeHandler
6
+
1
7
  Version 0.0.63
2
8
  * Enhancements
3
9
  * Interpret ERB for oauth credentials within oauth response. Needed for when params like 'username' can change in runtime
@@ -33,15 +33,25 @@ class Exchange
33
33
  @retry_for_success = false
34
34
  self.retry_count = 3
35
35
  @api_class.elements.each do |element|
36
- define_singleton_method(element.to_s.split('__custom_path_').last) do
36
+ element_name = element.to_s.split('__custom_path_').last
37
+ define_singleton_method(element_name) do
37
38
  @api_class.__send__(element, response) # Forward the call onto handler to retrieve the element for the response
38
39
  end
40
+ define_singleton_method("#{element_name}?") do
41
+ begin
42
+ __send__ element_name
43
+ true
44
+ rescue NoElementAtPath
45
+ false
46
+ end
47
+ end
39
48
  end
40
49
  end
41
50
 
42
51
  # Merge exchange initialized request params with ones set later on
43
52
  def merge_request_body
44
- if @override_parameters[:body]
53
+ if @override_parameters[:body] || default_params[:body]
54
+ @override_parameters[:body] ||= {}
45
55
  @override_parameters[:body].merge!(default_params[:body])
46
56
  @override_parameters
47
57
  else
@@ -113,6 +123,14 @@ class Exchange
113
123
  true
114
124
  end
115
125
 
126
+ # @return [Boolean] Whether an element exists at the path
127
+ def element?(path)
128
+ [path]
129
+ true
130
+ rescue NoElementAtPath
131
+ false
132
+ end
133
+
116
134
  # Extract value from path api class
117
135
  # @param [Object] path Path to return element for api class E.g - for SOAP this is XPath string. For JSON, this is Hash dig Array
118
136
  # @return [String] Value at path
@@ -114,8 +114,9 @@ module Soaspec
114
114
  }
115
115
  end
116
116
 
117
+ # Perform ERB on each header value
118
+ # @return [Hash] Hash from 'rest_client_headers' passed through ERB
117
119
  def parse_headers
118
- # rest_client_headers.map { |h| ERB.new(h).result(binding) }
119
120
  Hash[rest_client_headers.map { |k, header| [k, ERB.new(header).result(binding)] }]
120
121
  end
121
122
 
@@ -140,11 +141,12 @@ module Soaspec
140
141
  # Used in together with Exchange request that passes such override parameters
141
142
  # @param [Hash] override_parameters Params to characterize REST request
142
143
  # @param_value [params] Extra parameters (E.g. headers)
143
- # @param_value [suburl] URL appended to base_url of clss
144
+ # @param_value [suburl] URL appended to base_url of class
144
145
  # @param_value [method] REST method (get, post, etc)
145
146
  def make_request(override_parameters)
146
147
  test_values = override_parameters
147
148
  test_values[:params] ||= {}
149
+ test_values[:method] ||= :post
148
150
  test_values[:suburl] = test_values[:suburl].to_s if test_values[:suburl]
149
151
  test_values[:params][:params] = test_values[:q] if test_values[:q] # Use q for query parameters. Nested :params is ugly and long
150
152
 
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.63'.freeze
2
+ VERSION = '0.0.64'.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.63
4
+ version: 0.0.64
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA