soaspec 0.0.78 → 0.0.79
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/.gitlab-ci.yml +0 -5
- data/ChangeLog +5 -0
- data/Rakefile +2 -9
- data/exe/soaspec +1 -1
- data/lib/soaspec/exchange.rb +12 -5
- data/lib/soaspec/exchange_handlers/rest_handler.rb +0 -1
- data/lib/soaspec/exchange_handlers/soap_handler.rb +22 -17
- data/lib/soaspec/test_server/bank.wsdl +1 -1
- data/lib/soaspec/test_server/get_bank.rb +5 -0
- data/lib/soaspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc958fe0aac536d439cbc015ff650574599df2e1
|
4
|
+
data.tar.gz: 8010383ef455985729cc65abf1992afbd42749c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f330c9ae4275aa3d545aa523bc6abe20cd2a3a733430fefaf2dd23dfcac087232fda5ee64058e67aeab74cb53b341e4b205e14ab543136dc8e40bbcbfefb6e1
|
7
|
+
data.tar.gz: abcb93f6733a20288210f4175b44c94d83c91331e1008e7a2ed07c759ad475b9534542b93f888ff09bfd0767f64662629cac24f8cf311bd60caee8e9635e334d
|
data/.gitlab-ci.yml
CHANGED
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.79
|
2
|
+
* Enhancements
|
3
|
+
* `values_from_path` method on `SoapHandler` to easily extract multiple values for an xpath
|
4
|
+
* If `id` is specified on associated factory, FactoryBot will populate the primary factory with that id. See `rest/factory_spec` for eg
|
5
|
+
|
1
6
|
Version 0.0.78
|
2
7
|
* Enhancements
|
3
8
|
* Use 'thor' for `soaspec generate`, allowing less prompt and more options through command line. Added tests for it
|
data/Rakefile
CHANGED
@@ -5,18 +5,11 @@ require 'rake/clean'
|
|
5
5
|
ENV['folder'] ||= ''
|
6
6
|
ENV['test'] ||= ''
|
7
7
|
|
8
|
-
|
8
|
+
desc 'Run tests'
|
9
|
+
RSpec::Core::RakeTask.new(spec: %i[clean clobber start_test_server]) do |t|
|
9
10
|
t.pattern = "spec/**/#{ENV['folder']}*/#{ENV['test']}*_spec.rb"
|
10
|
-
t.exclude_pattern = 'spec/exe/*_spec.rb'
|
11
|
-
end
|
12
|
-
|
13
|
-
RSpec::Core::RakeTask.new(exe_spec: %i[start_test_server]) do |t|
|
14
|
-
t.pattern = 'spec/exe/*_spec.rb'
|
15
11
|
end
|
16
12
|
|
17
|
-
desc 'Run tests'
|
18
|
-
task spec: %w[clean clobber start_test_server run_spec]
|
19
|
-
|
20
13
|
task default: :spec
|
21
14
|
|
22
15
|
CLEAN.include 'tmp/*'
|
data/exe/soaspec
CHANGED
@@ -27,8 +27,8 @@ module Soaspec
|
|
27
27
|
option :ci, default: 'jenkins', banner: 'What Continuous Integration is used'
|
28
28
|
option :virtual, type: :boolean, default: true, banner: 'Whether to set things up for a virtual server'
|
29
29
|
def new(type = 'initial')
|
30
|
-
puts 'Creating files for soaspec'
|
31
30
|
@virtual = options[:virtual]
|
31
|
+
puts "Creating files for soaspec. options are #{options}"
|
32
32
|
create_file(filename: 'Gemfile')
|
33
33
|
create_file(filename: 'Rakefile')
|
34
34
|
create_file(filename: '.rspec')
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -30,7 +30,6 @@ end
|
|
30
30
|
# Essentially, params in the exchange that are set are related to the request
|
31
31
|
# What is returned is related to the response
|
32
32
|
class Exchange
|
33
|
-
|
34
33
|
extend ExchangeAccessors
|
35
34
|
|
36
35
|
# Instance of ExchangeHandler for which this exchange is made
|
@@ -42,6 +41,11 @@ class Exchange
|
|
42
41
|
# Expect Factory to fail upon trying to create
|
43
42
|
attr_writer :fail_factory
|
44
43
|
|
44
|
+
|
45
|
+
def values_from_path(path, attribute: nil)
|
46
|
+
exchange_handler.values_from_path(response, path, attribute: attribute)
|
47
|
+
end
|
48
|
+
|
45
49
|
# Set retry for success variable to true so that request will be retried
|
46
50
|
# for retry_count until it's true
|
47
51
|
def retry_for_success
|
@@ -194,13 +198,16 @@ class Exchange
|
|
194
198
|
# @param [Object] args Arguments passed to method
|
195
199
|
# @param [Object] block
|
196
200
|
def method_missing(method_name, *args, &block)
|
201
|
+
set_value = args.first
|
197
202
|
if method_name[-1] == '=' # A setter method
|
198
|
-
|
199
|
-
|
200
|
-
|
203
|
+
getter_name = method_name[0..-2]
|
204
|
+
if set_value.class < Exchange # This would be prerequisite exchange
|
205
|
+
define_singleton_method(getter_name) do
|
206
|
+
set_value
|
201
207
|
end
|
208
|
+
self[getter_name] = set_value.id if set_value.respond_to?(:id)
|
202
209
|
else
|
203
|
-
self[
|
210
|
+
self[getter_name] = set_value
|
204
211
|
end
|
205
212
|
else
|
206
213
|
super
|
@@ -158,21 +158,19 @@ module Soaspec
|
|
158
158
|
# Returns the value at the provided xpath
|
159
159
|
# @param [Savon::Response] response
|
160
160
|
# @param [String] xpath
|
161
|
-
# @
|
162
|
-
|
163
|
-
def xpath_value_for(response: nil, xpath: nil, attribute: nil)
|
161
|
+
# @return [Enumerable] Elements found through Xpath
|
162
|
+
def xpath_elements_for(response: nil, xpath: nil, attribute: nil)
|
164
163
|
raise ArgumentError('response and xpath must be passed to method') unless response && xpath
|
164
|
+
xpath = "//*[@#{attribute}]" unless attribute.nil?
|
165
|
+
xpath = '//' + xpath if xpath[0] != '/'
|
165
166
|
temp_doc = response.doc.dup
|
166
167
|
convert_to_lower_case(temp_doc) if convert_to_lower?
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
raise NoElementAtPath, "No value at Xpath '#{xpath}' in XML #{response.doc}" unless result
|
174
|
-
return result.inner_text if attribute.nil?
|
175
|
-
result.attributes[attribute].inner_text
|
168
|
+
if Soaspec.strip_namespaces? && !xpath.include?(':')
|
169
|
+
temp_doc.remove_namespaces!
|
170
|
+
temp_doc.xpath(xpath)
|
171
|
+
else
|
172
|
+
temp_doc.xpath(xpath, temp_doc.collect_namespaces)
|
173
|
+
end
|
176
174
|
end
|
177
175
|
|
178
176
|
# Based on a exchange, return the value at the provided xpath
|
@@ -182,16 +180,23 @@ module Soaspec
|
|
182
180
|
# @param [String] attribute Generic attribute to find. Will override path
|
183
181
|
# @return [String] Value at Xpath
|
184
182
|
def value_from_path(response, path, attribute: nil)
|
185
|
-
|
186
|
-
|
187
|
-
|
183
|
+
results = xpath_elements_for(response: response, xpath: path, attribute: attribute)
|
184
|
+
raise NoElementAtPath, "No value at Xpath '#{path}' in XML #{response.doc}" if results.empty?
|
185
|
+
return results.first.inner_text if attribute.nil?
|
186
|
+
results.first.attributes[attribute].inner_text
|
187
|
+
end
|
188
|
+
|
189
|
+
# @return [Enumerable] List of values returned from path
|
190
|
+
def values_from_path(response, path, attribute: nil)
|
191
|
+
xpath_elements_for(response: response, xpath: path, attribute: attribute).map(&:inner_text) # { |e| e.inner_text }
|
188
192
|
end
|
189
193
|
|
190
|
-
#
|
194
|
+
# alias elements xpath_elements_for
|
195
|
+
|
196
|
+
# @return [Boolean] Whether any of the keys of the Body Hash include value
|
191
197
|
def include_value?(response, expected_value)
|
192
198
|
response.body.include_value?(expected_value)
|
193
199
|
end
|
194
|
-
|
195
200
|
end
|
196
201
|
|
197
202
|
# Deprecated class name. Will be removed in the future
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<xsd:sequence>
|
20
20
|
<xsd:element minOccurs="0" name="bezeichnung" type="xsd:string"/>
|
21
21
|
<xsd:element minOccurs="0" name="bic" type="xsd:string"/>
|
22
|
-
<xsd:element minOccurs="0" name="ort" type="xsd:string"/>
|
22
|
+
<xsd:element maxOccurs="unbounded" minOccurs="0" name="ort" type="xsd:string"/>
|
23
23
|
<xsd:element minOccurs="0" name="plz" type="xsd:string"/>
|
24
24
|
</xsd:sequence>
|
25
25
|
</xsd:complexType>
|
@@ -21,6 +21,10 @@ module Soaspec
|
|
21
21
|
<ns1:bezeichnung lang="German"><%= @title %></ns1:bezeichnung>
|
22
22
|
<ns1:bic>DEUTDEMMXXX <%= soap_action %></ns1:bic>
|
23
23
|
<ns1:ort>München</ns1:ort>
|
24
|
+
<% if @multiple_ort %>
|
25
|
+
<ns1:ort>Wellington</ns1:ort>
|
26
|
+
<ns1:ort>Tokyo</ns1:ort>
|
27
|
+
<% end %>
|
24
28
|
<ns1:plz><%= @bank_name %></ns1:plz>
|
25
29
|
</ns1:details>
|
26
30
|
</ns1:getBankResponse>
|
@@ -147,6 +151,7 @@ module Soaspec
|
|
147
151
|
@bank_id = @bank_name.to_i
|
148
152
|
return 500, ERB.new(bank_not_found).result(binding) if @bank_id.zero?
|
149
153
|
@title = 'DAB Bank' if @bank_id == 500
|
154
|
+
@multiple_ort = (@bank_id == 20)
|
150
155
|
ERB.new(success_response_template).result(binding)
|
151
156
|
end
|
152
157
|
|
data/lib/soaspec/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.79
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|