soaspec 0.0.36 → 0.0.37
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 +5 -0
- data/Gemfile.lock +7 -7
- data/README.md +9 -4
- data/exe/soaspec-generate +1 -1
- data/exe/xml_to_yaml_file +1 -1
- data/lib/soaspec/accessors.rb +14 -1
- data/lib/soaspec/exchange.rb +35 -1
- data/lib/soaspec/exchange_handlers/rest_handler.rb +1 -0
- data/lib/soaspec/exchange_handlers/soap_handler.rb +10 -6
- data/lib/soaspec/exe_helpers.rb +0 -10
- 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: ab1cb8ee1d09d0721eb978f4ac7e40b6f33f7151
|
4
|
+
data.tar.gz: 77236d1a6feac34f99571fcabbfa4487df14ce82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b69397b682d8fa139f22ae921b6cb1497bd444acd821b9a79ac1c116bf963d9e59c1645e9f0faf02a946d14358f30ba79d7061e45905191b349f4c677866e284
|
7
|
+
data.tar.gz: 2cbfefe2deb59e4c582ca0012d118ae68afad55681859d408175c00c8d6494a988844da044f52a96df2c965f35597cb0b1cb2ffa9aa62a25eb27fd839181c3bc
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.37 / 2018-3-16
|
2
|
+
* Enhancements
|
3
|
+
* Made retry_for_success method to keep making request until 200 status code if set on exchange
|
4
|
+
* If '$' not included for json_path, by default a '$..' is added for convenience
|
5
|
+
|
1
6
|
Version 0.0.36 / 2018-3-15
|
2
7
|
* Bug fix
|
3
8
|
* Make test name log in correct place
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
soaspec (0.0.
|
4
|
+
soaspec (0.0.37)
|
5
5
|
jsonpath
|
6
6
|
rest-client (>= 2.0)
|
7
7
|
rspec (~> 3.0)
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
builder (>= 2.1.2)
|
31
31
|
http-cookie (1.0.3)
|
32
32
|
domain_name (~> 0.5)
|
33
|
-
httpi (2.4.
|
33
|
+
httpi (2.4.3)
|
34
34
|
rack
|
35
35
|
socksify
|
36
36
|
i18n (0.9.1)
|
@@ -44,12 +44,12 @@ GEM
|
|
44
44
|
mini_portile2 (2.3.0)
|
45
45
|
multi_json (1.13.1)
|
46
46
|
netrc (0.11.0)
|
47
|
-
nokogiri (1.8.
|
47
|
+
nokogiri (1.8.2)
|
48
48
|
mini_portile2 (~> 2.3.0)
|
49
|
-
nokogiri (1.8.
|
49
|
+
nokogiri (1.8.2-x64-mingw32)
|
50
50
|
mini_portile2 (~> 2.3.0)
|
51
51
|
nori (2.6.0)
|
52
|
-
rack (2.0.
|
52
|
+
rack (2.0.4)
|
53
53
|
rake (12.2.1)
|
54
54
|
require_all (1.5.0)
|
55
55
|
rest-client (2.0.2)
|
@@ -79,12 +79,12 @@ GEM
|
|
79
79
|
rspec-support (3.7.0)
|
80
80
|
rspec_junit_formatter (0.3.0)
|
81
81
|
rspec-core (>= 2, < 4, != 2.12.0)
|
82
|
-
savon (2.
|
82
|
+
savon (2.12.0)
|
83
83
|
akami (~> 1.2)
|
84
84
|
builder (>= 2.1.2)
|
85
85
|
gyoku (~> 1.2)
|
86
86
|
httpi (~> 2.3)
|
87
|
-
nokogiri (>= 1.
|
87
|
+
nokogiri (>= 1.8.1)
|
88
88
|
nori (~> 2.4)
|
89
89
|
wasabi (~> 3.4)
|
90
90
|
socksify (1.7.1)
|
data/README.md
CHANGED
@@ -21,9 +21,11 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Todo
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
Potentially have in built use of 'vcr' and 'http_stub' gems
|
24
|
+
* Give examples and convenience methods for building classes for each SOAP or REST operation
|
25
|
+
* Handle REST template (similar way to REST)
|
26
|
+
* Potentially have in built use of 'vcr' and 'http_stub' gems
|
27
|
+
* Handle proxies to record traffic for MiddleWare testing
|
28
|
+
* Much more
|
27
29
|
|
28
30
|
## Getting Started
|
29
31
|
|
@@ -44,10 +46,13 @@ Then you can run the tests with:
|
|
44
46
|
rake spec
|
45
47
|
```
|
46
48
|
|
49
|
+
You can also use `soaspec-generate` to generate a set of tests from a WSDL. This is still in trial period
|
50
|
+
|
47
51
|
## Usage
|
48
52
|
|
49
|
-
* SOAP - this uses Savon behind the scenes. Some defaults are overridden. Please see '
|
53
|
+
* SOAP - this uses Savon behind the scenes. Some defaults are overridden. Please see 'soap_handler.rb'-'default_options' method
|
50
54
|
for such defaults. When describing an API override this in 'savon_options' method
|
55
|
+
* REST - this uses the resource class from the Rest-Client gem behind the scenes.
|
51
56
|
|
52
57
|
See specs for example of usage. This will be added to later.
|
53
58
|
|
data/exe/soaspec-generate
CHANGED
@@ -162,7 +162,7 @@ create_file filename: "lib/#{@name.snakecase}.rb", content: ERB.new(@class_conte
|
|
162
162
|
if details[:parameters]
|
163
163
|
details[:parameters].each do |element, details|
|
164
164
|
@use_camel_case = true if (/[[:upper:]]/.match(element.to_s[0]) != nil)
|
165
|
-
@content += " #{
|
165
|
+
@content += " #{element.snakecase}: #{fill_in_field_from_type(details[:type])} # #{details[:type]} \n"
|
166
166
|
# TODO: If details is a Hash need to loop again
|
167
167
|
end
|
168
168
|
end
|
data/exe/xml_to_yaml_file
CHANGED
data/lib/soaspec/accessors.rb
CHANGED
@@ -6,6 +6,19 @@ module Soaspec
|
|
6
6
|
# Defines expected_mandatory_elements method used in 'success_scenario' shared examples
|
7
7
|
# to indicate certain elements must be present
|
8
8
|
# @param [Array] elements Array of symbols specifying expected element names for 'success scenario' in snakecase
|
9
|
+
#
|
10
|
+
# @example Inside class
|
11
|
+
# mandatory_elements :GetWeatherResult
|
12
|
+
#
|
13
|
+
# Or for a list
|
14
|
+
#
|
15
|
+
# @example Inside class
|
16
|
+
# mandatory_elements [:GetWeatherResult, :GetResultStatus]
|
17
|
+
#
|
18
|
+
# In test
|
19
|
+
# describe Exchange(:name) do
|
20
|
+
# it_behaves_like 'success scenario' # Includes checks for mandatory elements
|
21
|
+
# end
|
9
22
|
def mandatory_elements(elements)
|
10
23
|
define_method('expected_mandatory_elements') do
|
11
24
|
return [elements] if elements.is_a?(String) || elements.is_a?(Symbol)
|
@@ -41,7 +54,7 @@ module Soaspec
|
|
41
54
|
# end
|
42
55
|
#
|
43
56
|
def mandatory_json_values(json_value_pairs)
|
44
|
-
raise ArgumentError(
|
57
|
+
raise ArgumentError("Hash of {'jsonpath' => expected values} expected") unless json_value_pairs.is_a? Hash
|
45
58
|
define_method('expected_mandatory_json_values') do
|
46
59
|
json_value_pairs
|
47
60
|
end
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -4,6 +4,20 @@ require_relative '../soaspec'
|
|
4
4
|
class Exchange
|
5
5
|
|
6
6
|
attr_reader :api_class
|
7
|
+
# How many times to retry for a success
|
8
|
+
attr_accessor :retry_count
|
9
|
+
|
10
|
+
# Set retry for success variable to true so that request will be retried
|
11
|
+
# for retry_count until it's true
|
12
|
+
def retry_for_success
|
13
|
+
@retry_for_success = true
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Bool] Whether to keep making request until success code reached
|
18
|
+
def retry_for_success?
|
19
|
+
@retry_for_success
|
20
|
+
end
|
7
21
|
|
8
22
|
# @param [Symbol, String] name Name shown in RSpec run
|
9
23
|
# @param [Hash] override_parameters Parameters to override for default params
|
@@ -11,12 +25,21 @@ class Exchange
|
|
11
25
|
@test_name = name.to_s
|
12
26
|
@api_class = Soaspec::Environment.api_handler
|
13
27
|
@override_parameters = override_parameters
|
28
|
+
@retry_for_success = false
|
29
|
+
self.retry_count = 3
|
14
30
|
end
|
15
31
|
|
16
32
|
# Make request to handler with parameters defined
|
33
|
+
# Will retry until success code reached if retry_for_success? is set
|
34
|
+
# @return [Response] Response from Api handler
|
17
35
|
def make_request
|
18
36
|
Soaspec::SpecLogger.add_to 'Example ' + @test_name
|
19
|
-
|
37
|
+
retry_count.times do
|
38
|
+
response = @api_class.make_request(@override_parameters)
|
39
|
+
return response unless retry_for_success?
|
40
|
+
return response if @api_class.status_code_for(response) == 200
|
41
|
+
response
|
42
|
+
end
|
20
43
|
end
|
21
44
|
|
22
45
|
# Name describing this class when used with `RSpec.describe`
|
@@ -40,6 +63,17 @@ class Exchange
|
|
40
63
|
@api_class.status_code_for(response)
|
41
64
|
end
|
42
65
|
|
66
|
+
# Dummy request used to make a request without verifying it and ignoring WSDL errors
|
67
|
+
# @return [Boolean] Always returns true. Unless of course an unexpected exception occurs
|
68
|
+
def dummy_request
|
69
|
+
make_request
|
70
|
+
true
|
71
|
+
rescue Savon::HTTPError
|
72
|
+
puts 'Resolver error'
|
73
|
+
# This seems to occur first time IP address asks for WSDL
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
43
77
|
# Extract value from path api class
|
44
78
|
# @param [Object] path Path to return element for api class E.g - for SOAP this is XPath string. For JSON, this is Hash dig Array
|
45
79
|
# @return [String] Value at path
|
@@ -227,6 +227,7 @@ module Soaspec
|
|
227
227
|
path = '//' + path if path[0] != '/'
|
228
228
|
xpath_value_for(exchange: exchange, xpath: path)
|
229
229
|
when :json
|
230
|
+
path = '$..' + path if path[0] != '$'
|
230
231
|
matching_values = JsonPath.on(exchange.response.body, path)
|
231
232
|
raise NoElementInHash, "Element in #{exchange.response.body} not found with path '#{path}'" if matching_values.empty?
|
232
233
|
matching_values.first
|
@@ -84,12 +84,16 @@ module Soaspec
|
|
84
84
|
test_values = override_parameters # Used in Erb
|
85
85
|
# Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request
|
86
86
|
test_values = test_values.transform_keys_to_symbols if Soaspec::Environment.always_use_keys?
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
@
|
87
|
+
begin
|
88
|
+
if @request_option == :template
|
89
|
+
request_body = File.read('template/' + template_name + '.xml')
|
90
|
+
render_body = ERB.new(request_body).result(binding)
|
91
|
+
@client.call(operation, xml: render_body) # Call the SOAP operation with the request XML provided
|
92
|
+
elsif @request_option == :hash
|
93
|
+
@client.call(operation, message: @default_hash.merge(test_values), attributes: request_root_attributes)
|
94
|
+
end
|
95
|
+
rescue Savon::HTTPError => e
|
96
|
+
e
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
data/lib/soaspec/exe_helpers.rb
CHANGED
@@ -123,15 +123,5 @@ Reports are shown in the 'logs' folder. By default Rake produces a junit, an htm
|
|
123
123
|
EOF
|
124
124
|
end
|
125
125
|
|
126
|
-
# Convert key in camelcase to underscore separated (snakecase)
|
127
|
-
def underscore_key(key)
|
128
|
-
key.to_s.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
129
|
-
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
130
|
-
.tr('-', '_')
|
131
|
-
.gsub(/\s/, '_')
|
132
|
-
.gsub(/__+/, '_')
|
133
|
-
.downcase
|
134
|
-
end
|
135
|
-
|
136
126
|
end
|
137
127
|
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.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|