soaspec 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/lib/soaspec/basic_soap_handler.rb +10 -0
- data/lib/soaspec/exchange.rb +7 -3
- data/lib/soaspec/hash_methods.rb +15 -5
- data/lib/soaspec/matchers.rb +10 -0
- data/lib/soaspec/shared_examples.rb +9 -0
- data/lib/soaspec/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b4452d636edba383d91b460bf2a53ea47957ec2
|
4
|
+
data.tar.gz: fa67e6a673bf4c1468570f30520e1ad79d764ad3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49b74f30a8f0bce484e0993be7214c1ffdf69cf38bde63bed506f1434bce94b16a8cf1f708d90092a239f675cb76e156c74f3c496c0aba89a0e296155cc5f22f
|
7
|
+
data.tar.gz: b3290ad9ed129d0628565d762a920d833652824921b1e28927aa19ccf2979c6938a5146cd6934c77ec8d5e84f26a40fabed987b94f39e7a6ba8989533c14e071
|
data/ChangeLog
ADDED
data/Gemfile.lock
CHANGED
@@ -101,5 +101,15 @@ module Soaspec
|
|
101
101
|
@default_hash = hash
|
102
102
|
end
|
103
103
|
|
104
|
+
def status_code_for(response)
|
105
|
+
response.http.code
|
106
|
+
end
|
107
|
+
|
108
|
+
# Override this to specify elements that must be present in the response
|
109
|
+
# Make it an Array of keys
|
110
|
+
def mandatory_elements
|
111
|
+
nil
|
112
|
+
end
|
113
|
+
|
104
114
|
end
|
105
115
|
end
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -21,7 +21,7 @@ class Exchange
|
|
21
21
|
# Name describing this class when used with `RSpec.describe`
|
22
22
|
# @return [String] Name given when initializing
|
23
23
|
def to_s
|
24
|
-
@response =
|
24
|
+
@response = make_request
|
25
25
|
if Soaspec::Environment.api_handler.class < Soaspec::BasicSoapHandler
|
26
26
|
@xml_response = @response.to_xml
|
27
27
|
@xml_doc = @response.doc
|
@@ -32,7 +32,11 @@ class Exchange
|
|
32
32
|
def contain(value)
|
33
33
|
@xml_response.include? value
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
|
+
def mandatory_elements
|
37
|
+
Soaspec::Environment.api_handler.mandatory_elements
|
38
|
+
end
|
39
|
+
|
36
40
|
# Returns Savon response
|
37
41
|
# response.body (body of response as Hash)
|
38
42
|
# response.header (head of response as Hash)
|
@@ -41,7 +45,7 @@ class Exchange
|
|
41
45
|
end
|
42
46
|
|
43
47
|
def status_code
|
44
|
-
@response
|
48
|
+
Soaspec::Environment.api_handler.status_code_for(@response)
|
45
49
|
end
|
46
50
|
|
47
51
|
end
|
data/lib/soaspec/hash_methods.rb
CHANGED
@@ -15,12 +15,22 @@ class Hash
|
|
15
15
|
|
16
16
|
# Value present in nested Hash
|
17
17
|
def include_value?(value)
|
18
|
-
|
18
|
+
each_value do |v|
|
19
19
|
return true if v == value
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
next unless v.is_a? Hash
|
21
|
+
v.each_value do |v|
|
22
|
+
return true if v == value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
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
|
24
34
|
end
|
25
35
|
end
|
26
36
|
false
|
data/lib/soaspec/matchers.rb
CHANGED
@@ -11,6 +11,16 @@ RSpec::Matchers.define :contain_value do |expected|
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
RSpec::Matchers.define :contain_key do |expected|
|
15
|
+
match do |actual|
|
16
|
+
expect(actual.response.body.include_key?(expected)).to be true
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message do |actual|
|
20
|
+
"expected that #{actual.response.body} would contain key #{expected}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
14
24
|
RSpec::Matchers.define :have_element_at_xpath do |expected|
|
15
25
|
match do |exchange|
|
16
26
|
expect(exchange.xml_doc.at_xpath(expected, Soaspec::Environment.api_handler.namespaces).content).not_to be_empty
|
@@ -4,4 +4,13 @@ shared_examples_for 'success scenario' do
|
|
4
4
|
it 'has status code of 200' do
|
5
5
|
expect(described_class.status_code).to eq 200
|
6
6
|
end
|
7
|
+
if described_class.mandatory_elements
|
8
|
+
context 'has expected mandatory elements' do
|
9
|
+
described_class.mandatory_elements.each do |mandatory_element|
|
10
|
+
it "#{mandatory_element} element" do
|
11
|
+
expect(described_class).to contain_key mandatory_element
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
7
16
|
end
|
data/lib/soaspec/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- ".rspec"
|
108
108
|
- ".travis.yml"
|
109
109
|
- CODE_OF_CONDUCT.md
|
110
|
+
- ChangeLog
|
110
111
|
- Gemfile
|
111
112
|
- Gemfile.lock
|
112
113
|
- LICENSE.txt
|