soaspec 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b4452d636edba383d91b460bf2a53ea47957ec2
4
- data.tar.gz: fa67e6a673bf4c1468570f30520e1ad79d764ad3
3
+ metadata.gz: 94c09dc736076e7a885813bff6f82fb4542d5aee
4
+ data.tar.gz: c8c9ab3703b8ed38358f2fd8d840d81d4fff4431
5
5
  SHA512:
6
- metadata.gz: 49b74f30a8f0bce484e0993be7214c1ffdf69cf38bde63bed506f1434bce94b16a8cf1f708d90092a239f675cb76e156c74f3c496c0aba89a0e296155cc5f22f
7
- data.tar.gz: b3290ad9ed129d0628565d762a920d833652824921b1e28927aa19ccf2979c6938a5146cd6934c77ec8d5e84f26a40fabed987b94f39e7a6ba8989533c14e071
6
+ metadata.gz: 82bf609a95402240f1af578266ca891f37f96d5f947b4fe48a99c2e35b94d1a2e5ea3be78b5c215a6de350dedfc7f91e83ec9a71b37fd7ed188f191c97a97f76
7
+ data.tar.gz: 22c17de478c533f2d6a79c5a19276391d1dcfe877cae518fda76866b5961ea52ef47e0d239738a0f21772a25de09d20095184524ae381cb61184589cf358c234
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.0.8 / 2018-1-19
2
+ * Enhancements
3
+ * Added root_attributes method to add attribute to the root class
4
+
1
5
  Version 0.0.7 / 2018-1-19
2
6
  * Enhancements
3
7
  * Added contain_key matcher
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soaspec (0.0.7)
4
+ soaspec (0.0.8)
5
5
  rest-client (>= 2.0)
6
6
  rspec (~> 3.0)
7
7
  savon (>= 2)
data/README.md CHANGED
@@ -30,7 +30,19 @@ Potentially have in built use of vcr and http_stub gems
30
30
  See specs for example of usage. This will be added to later.
31
31
 
32
32
  It is recommended that a class be created representing a Web Service Operation or REST call. Then tests refer back to
33
- that class. See get_weather_web_service class in spec/soaspec/soap folder for example
33
+ that class. See get_weather_web_service class in spec/soaspec/soap folder for example.
34
+
35
+ ### Recommended
36
+
37
+ If you find having a large backtrace on errors or RSpec shared examples such as 'success scenarios' this can shorten the
38
+ backtrace.
39
+
40
+ RSpec.configure do |config|
41
+
42
+ config.backtrace_exclusion_patterns = [
43
+ /rspec/
44
+ ]
45
+ end
34
46
 
35
47
  ## Development
36
48
 
data/exe/soaspec-init CHANGED
@@ -62,6 +62,13 @@ spec_helper_content = <<-EOF
62
62
 
63
63
  require 'soaspec'
64
64
 
65
+ RSpec.configure do |config|
66
+ # This will make backtrace much shorter by removing many lines from rspec failure message
67
+ config.backtrace_exclusion_patterns = [
68
+ /rspec/
69
+ ]
70
+ end
71
+
65
72
  EOF
66
73
 
67
74
  soap_spec_content = <<-EOF
@@ -83,7 +83,7 @@ module Soaspec
83
83
  render_body = ERB.new(request_body).result(binding)
84
84
  @client.call(default_operation, xml: render_body ) # Call the SOAP operation with the request XML provided
85
85
  elsif @request_option == :hash
86
- @client.call(default_operation, message: @default_hash.merge(test_values))
86
+ @client.call(default_operation, message: @default_hash.merge(test_values), attributes: root_attributes)
87
87
  end
88
88
  end
89
89
 
@@ -111,5 +111,9 @@ module Soaspec
111
111
  nil
112
112
  end
113
113
 
114
+ def root_attributes
115
+ nil
116
+ end
117
+
114
118
  end
115
119
  end
@@ -19,22 +19,20 @@ class Exchange
19
19
  end
20
20
 
21
21
  # Name describing this class when used with `RSpec.describe`
22
+ # This will make the request and store the response
22
23
  # @return [String] Name given when initializing
23
24
  def to_s
24
25
  @response = make_request
25
- if Soaspec::Environment.api_handler.class < Soaspec::BasicSoapHandler
26
+ if @api_class.class < Soaspec::BasicSoapHandler
26
27
  @xml_response = @response.to_xml
27
28
  @xml_doc = @response.doc
28
29
  end
29
30
  @test_name
30
31
  end
31
32
 
32
- def contain(value)
33
- @xml_response.include? value
34
- end
35
-
33
+ # Elements a shared 'success scenario' is expected to have
36
34
  def mandatory_elements
37
- Soaspec::Environment.api_handler.mandatory_elements
35
+ @api_class.mandatory_elements
38
36
  end
39
37
 
40
38
  # Returns Savon response
@@ -45,7 +43,7 @@ class Exchange
45
43
  end
46
44
 
47
45
  def status_code
48
- Soaspec::Environment.api_handler.status_code_for(@response)
46
+ @api_class.status_code_for(@response)
49
47
  end
50
48
 
51
49
  end
@@ -13,27 +13,38 @@ class Hash
13
13
  inject({}){|memo, (k, v)| memo[k.to_sym] = Hash.transform_keys_to_symbols(v); memo}
14
14
  end
15
15
 
16
- # Value present in nested Hash
16
+ def find_all_values_for(key)
17
+ result = []
18
+ result << self[key]
19
+ self.values.each do |hash_value|
20
+ values = [hash_value] unless hash_value.is_a? Array
21
+ values.each do |value|
22
+ result += value.find_all_values_for(key) if value.is_a? Hash
23
+ end
24
+ end
25
+ result.compact
26
+ end
27
+
28
+ # Value present in nested Hash.
17
29
  def include_value?(value)
18
30
  each_value do |v|
19
31
  return true if v == value
20
32
  next unless v.is_a? Hash
21
33
  v.each_value do |v|
22
34
  return true if v == value
35
+ next unless v.is_a? Hash
36
+ v.each_value do |v|
37
+ return true if v == value
38
+ end
23
39
  end
24
40
  end
25
41
  false
26
42
  end
27
43
 
44
+ # Whether key is present at least once
28
45
  def include_key?(key)
29
- each do |k, v|
30
- return true if k == key
31
- next unless v.is_a? Hash
32
- v.each do |k, v|
33
- return true if k == key
34
- end
35
- end
36
- false
46
+ result = find_all_values_for key
47
+ result != []
37
48
  end
38
49
 
39
50
  end
@@ -7,7 +7,7 @@ shared_examples_for 'success scenario' do
7
7
  if described_class.mandatory_elements
8
8
  context 'has expected mandatory elements' do
9
9
  described_class.mandatory_elements.each do |mandatory_element|
10
- it "#{mandatory_element} element" do
10
+ it mandatory_element do
11
11
  expect(described_class).to contain_key mandatory_element
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-18 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler