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 +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +13 -1
- data/exe/soaspec-init +7 -0
- data/lib/soaspec/basic_soap_handler.rb +5 -1
- data/lib/soaspec/exchange.rb +5 -7
- data/lib/soaspec/hash_methods.rb +20 -9
- data/lib/soaspec/shared_examples.rb +1 -1
- 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: 94c09dc736076e7a885813bff6f82fb4542d5aee
|
4
|
+
data.tar.gz: c8c9ab3703b8ed38358f2fd8d840d81d4fff4431
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82bf609a95402240f1af578266ca891f37f96d5f947b4fe48a99c2e35b94d1a2e5ea3be78b5c215a6de350dedfc7f91e83ec9a71b37fd7ed188f191c97a97f76
|
7
|
+
data.tar.gz: 22c17de478c533f2d6a79c5a19276391d1dcfe877cae518fda76866b5961ea52ef47e0d239738a0f21772a25de09d20095184524ae381cb61184589cf358c234
|
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
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
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -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
|
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
|
-
|
33
|
-
@xml_response.include? value
|
34
|
-
end
|
35
|
-
|
33
|
+
# Elements a shared 'success scenario' is expected to have
|
36
34
|
def mandatory_elements
|
37
|
-
|
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
|
-
|
46
|
+
@api_class.status_code_for(@response)
|
49
47
|
end
|
50
48
|
|
51
49
|
end
|
data/lib/soaspec/hash_methods.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
30
|
-
|
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
|
10
|
+
it mandatory_element do
|
11
11
|
expect(described_class).to contain_key mandatory_element
|
12
12
|
end
|
13
13
|
end
|
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.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-
|
11
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|