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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8c8aa2d7043e85afff8aa33c899d6e07ea9c9f2
4
- data.tar.gz: 5a0e202e250073d91b16577e84f79ab6d39160dd
3
+ metadata.gz: c0a3e540292329987ba8c0a2fd1e260b1331149c
4
+ data.tar.gz: 23c0a28e63b2afb2005ed7966317758a93a8e074
5
5
  SHA512:
6
- metadata.gz: 5d57d63f7456ae2e9b4f26884449e63ff0051ba7461182fb42d2bf108686576b388679cd8e5dd20dee7fe141db97973f6b1d87643a5398f789d3f85fe8ded562
7
- data.tar.gz: 0be433e751ff4194e4c360d7dd285cf03e9333ef05481d2ea4220574b85b254c20c3c7a9366af96e56467bb310d93fbdfcbdf000bbe303d397b6f53c5721314c
6
+ metadata.gz: 72f4b5a1a14c627b72439219494cc9166858961d6380b44ea62757d91ad6f9ba5592196e2f767e2ebf6752b7909af457f430eb989c18c38297a5cf7b49091421
7
+ data.tar.gz: d57c6076794ab593d6962a56e16afeddf6cfe47f5a213fd386191ed6e7edeeaf4981911e3c89f96c28fb8d3b447779fb0486be5c626660e008e5d72b81d9f565
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.0.12 / 2018/1-22
2
+ * Enhancements
3
+ * Example name added to log file
4
+
1
5
  Version 0.0.10 / 2018-1-21
2
6
  * Enhancements
3
7
  * Added [] method to perform xpath assertion
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soaspec (0.0.10)
4
+ soaspec (0.0.11)
5
5
  rest-client (>= 2.0)
6
6
  rspec (~> 3.0)
7
7
  rspec-its (>= 1.2.0)
@@ -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: file_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
- @name = name
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
@@ -18,6 +18,7 @@ class Exchange
18
18
  # This will make the request and store the response
19
19
  # @return [String] Name given when initializing
20
20
  def to_s
21
+ Soaspec::SpecLogger.add_to 'Example ' + @test_name
21
22
  @response = make_request
22
23
  @test_name
23
24
  end
@@ -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
@@ -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
- # Load default groups. Set name
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
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
data/lib/soaspec.rb CHANGED
@@ -14,6 +14,7 @@ require 'soaspec/exchange'
14
14
  require 'soaspec/matchers'
15
15
  require 'soaspec/shared_examples'
16
16
  require 'soaspec/hash_methods'
17
+ require 'soaspec/spec_logger'
17
18
 
18
19
  # Gem for handling SOAP and REST api tests
19
20
  module Soaspec
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.11
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-21 00:00:00.000000000 Z
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