soaspec 0.0.78 → 0.0.79

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: 81af3fccf7fe08aef640bb651f3db64a35becdee
4
- data.tar.gz: 4f3147e1f49580a340a698adf1531da764f21d58
3
+ metadata.gz: fc958fe0aac536d439cbc015ff650574599df2e1
4
+ data.tar.gz: 8010383ef455985729cc65abf1992afbd42749c9
5
5
  SHA512:
6
- metadata.gz: '049af0af886c7087970fc9825afbbe1590a5088ce0cdcc60db865d1d8271578dba801c5603c50bdc1d44e38d920513612f0ccb724e30eca5551f4d19062dfb32'
7
- data.tar.gz: a03feb257476d536b6cc03a4ce7c05939b90660d847dbae522f4d667be991596434c21f988361a28d94fee7f5f26afcda70b8759ab84c28cc48a44a703d1bfb2
6
+ metadata.gz: 3f330c9ae4275aa3d545aa523bc6abe20cd2a3a733430fefaf2dd23dfcac087232fda5ee64058e67aeab74cb53b341e4b205e14ab543136dc8e40bbcbfefb6e1
7
+ data.tar.gz: abcb93f6733a20288210f4175b44c94d83c91331e1008e7a2ed07c759ad475b9534542b93f888ff09bfd0767f64662629cac24f8cf311bd60caee8e9635e334d
@@ -13,11 +13,6 @@ rspec:
13
13
  paths:
14
14
  - coverage/
15
15
 
16
- exe_spec:
17
- stage: test
18
- script:
19
- - bundle exec rake exe_spec
20
-
21
16
  cucumber:
22
17
  stage: test
23
18
  script:
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
- RSpec::Core::RakeTask.new(:run_spec) do |t|
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/*'
@@ -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')
@@ -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
- if args.first.class < Exchange # This would be prerequisite exchange
199
- define_singleton_method(method_name[0..-2]) do
200
- args.first
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[method_name[0..-2]] = args.first
210
+ self[getter_name] = set_value
204
211
  end
205
212
  else
206
213
  super
@@ -58,7 +58,6 @@ module Soaspec
58
58
  end
59
59
  Soaspec::SpecLogger.add_to("response_headers: #{response.headers}")
60
60
  Soaspec::SpecLogger.add_to("response_body: #{response.body}")
61
- Soaspec::SpecLogger.add_to("response: #{response}")
62
61
  JSON.parse(response)
63
62
  end
64
63
 
@@ -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
- # @param [String] attribute Generic attribute to find
162
- # @return [String] Value inside element found through Xpath
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
- 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
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
- path = "//*[@#{attribute}]" unless attribute.nil?
186
- path = '//' + path if path[0] != '/'
187
- xpath_value_for(response: response, xpath: path, attribute: attribute)
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
- # Whether any of the keys of the Body Hash include value
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
 
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.78'.freeze
2
+ VERSION = '0.0.79'.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.78
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-24 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler