soaspec 0.0.11 → 0.0.12
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/lib/soaspec/basic_soap_handler.rb +3 -10
- data/lib/soaspec/exchange.rb +1 -0
- data/lib/soaspec/spec_logger.rb +18 -0
- data/lib/soaspec/tester.rb +13 -13
- data/lib/soaspec/version.rb +1 -1
- data/lib/soaspec.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0a3e540292329987ba8c0a2fd1e260b1331149c
|
4
|
+
data.tar.gz: 23c0a28e63b2afb2005ed7966317758a93a8e074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72f4b5a1a14c627b72439219494cc9166858961d6380b44ea62757d91ad6f9ba5592196e2f767e2ebf6752b7909af457f430eb989c18c38297a5cf7b49091421
|
7
|
+
data.tar.gz: d57c6076794ab593d6962a56e16afeddf6cfe47f5a213fd386191ed6e7edeeaf4981911e3c89f96c28fb8d3b447779fb0486be5c626660e008e5d72b81d9f565
|
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
|
2
|
-
require 'yaml'
|
3
2
|
require_relative 'tester'
|
4
3
|
require_relative 'hash_methods'
|
5
4
|
|
@@ -16,7 +15,7 @@ module Soaspec
|
|
16
15
|
{
|
17
16
|
log: true, # See request and response. (Put this in traffic file)
|
18
17
|
log_level: :debug,
|
19
|
-
logger:
|
18
|
+
logger: Soaspec::SpecLogger.create,
|
20
19
|
pretty_print_xml: true # Prints XML pretty
|
21
20
|
}
|
22
21
|
end
|
@@ -49,12 +48,11 @@ module Soaspec
|
|
49
48
|
# Setup object to handle communicating with a particular SOAP WSDL
|
50
49
|
# @param [Hash] specific_options Options defining SOAP request. WSDL, authentication, see http://savonrb.com/version2/globals.html for list of options
|
51
50
|
def initialize(name, specific_options = {})
|
52
|
-
super
|
53
51
|
options = default_options.merge logging_options
|
54
52
|
options.merge! savon_options
|
55
53
|
options.merge!(specific_options)
|
56
54
|
@client = Savon.client(options)
|
57
|
-
|
55
|
+
super
|
58
56
|
end
|
59
57
|
|
60
58
|
def name(name)
|
@@ -72,8 +70,8 @@ module Soaspec
|
|
72
70
|
def make_request(override_parameters)
|
73
71
|
test_values = override_parameters # Used in Erb
|
74
72
|
# Erb parses template file, executing Ruby code in `<% %>` blocks to work out final request
|
73
|
+
test_values = test_values.transform_keys_to_symbols # Either string or symbol
|
75
74
|
if @request_option == :template
|
76
|
-
test_values = test_values.transform_keys_to_symbols # Either string or symbol
|
77
75
|
request_body = File.read('template/' + template_name + '.xml')
|
78
76
|
render_body = ERB.new(request_body).result(binding)
|
79
77
|
@client.call(operation, xml: render_body) # Call the SOAP operation with the request XML provided
|
@@ -82,11 +80,6 @@ module Soaspec
|
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
85
|
-
def to_s
|
86
|
-
Soaspec::Environment.api_handler = self # Sets this variable globally. This is used in 'Exchange' class
|
87
|
-
@name
|
88
|
-
end
|
89
|
-
|
90
83
|
def default_hash=(hash)
|
91
84
|
@request_option = :hash
|
92
85
|
@default_hash = hash
|
data/lib/soaspec/exchange.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module Soaspec
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
# Handles logs of API requests and responses
|
6
|
+
class SpecLogger
|
7
|
+
def self.create
|
8
|
+
@logger = Logger.new('logs/traffic.log') # Where request and responses of APIs are stored
|
9
|
+
@logger.level = Logger::DEBUG
|
10
|
+
@logger
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.add_to(message)
|
14
|
+
@logger.info(message)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/soaspec/tester.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
|
2
|
-
require 'yaml'
|
3
|
-
|
4
2
|
module Soaspec
|
5
3
|
# Has basic methods common for methods defining RSpec tests in YAML
|
6
4
|
class Tester
|
7
5
|
|
6
|
+
# Retrieve the name of the template file to be used in the API request
|
8
7
|
attr_reader :template_name
|
9
8
|
|
10
|
-
#
|
9
|
+
# Set instance variable name
|
10
|
+
# @param [String, Symbol] name Name used when describing API test
|
11
|
+
# @param [Hash] options Parameters defining
|
11
12
|
def initialize(name, options)
|
12
13
|
@name = name
|
13
14
|
end
|
14
15
|
|
16
|
+
# Sets api handler variable globally. This is used in 'Exchange' class
|
17
|
+
# @return [String] Name set upon initialisation
|
18
|
+
def to_s
|
19
|
+
Soaspec::Environment.api_handler = self
|
20
|
+
@name
|
21
|
+
end
|
22
|
+
|
23
|
+
# Set the request option type and the template name
|
24
|
+
# @param [String] name Name of file inside 'template' folder excluding extension
|
15
25
|
def template_name=(name)
|
16
26
|
@request_option = :template
|
17
27
|
@template_name = name
|
18
28
|
end
|
19
29
|
|
20
|
-
protected
|
21
|
-
|
22
|
-
# Log API request and response traffic in 'logs/traffic.log'
|
23
|
-
# @return [Logger] Ruby logger that will log to 'logs/traffic.log'
|
24
|
-
def file_logger
|
25
|
-
logger = Logger.new('logs/traffic.log') # Where request and responses of APIs are stored
|
26
|
-
logger.level = Logger::DEBUG
|
27
|
-
logger
|
28
|
-
end
|
29
|
-
|
30
30
|
end
|
31
31
|
end
|
data/lib/soaspec/version.rb
CHANGED
data/lib/soaspec.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.12
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/soaspec/hash_methods.rb
|
137
137
|
- lib/soaspec/matchers.rb
|
138
138
|
- lib/soaspec/shared_examples.rb
|
139
|
+
- lib/soaspec/spec_logger.rb
|
139
140
|
- lib/soaspec/tester.rb
|
140
141
|
- lib/soaspec/version.rb
|
141
142
|
- soaspec.gemspec
|