soaspec 0.2.29 → 0.2.30

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +6 -0
  3. data/Gemfile +2 -0
  4. data/Rakefile +3 -1
  5. data/exe/soaspec +1 -0
  6. data/exe/xml_to_yaml_file +1 -0
  7. data/lib/soaspec/core_ext/hash.rb +2 -0
  8. data/lib/soaspec/cucumber/generic_steps.rb +2 -0
  9. data/lib/soaspec/demo.rb +2 -0
  10. data/lib/soaspec/errors.rb +3 -2
  11. data/lib/soaspec/exchange/exchange.rb +18 -6
  12. data/lib/soaspec/exchange/exchange_extractor.rb +3 -1
  13. data/lib/soaspec/exchange/exchange_properties.rb +2 -0
  14. data/lib/soaspec/exchange/exchange_repeater.rb +2 -0
  15. data/lib/soaspec/exchange/request_builder.rb +2 -0
  16. data/lib/soaspec/exchange/variable_storer.rb +2 -0
  17. data/lib/soaspec/exchange_handlers/exchange_handler.rb +8 -40
  18. data/lib/soaspec/exchange_handlers/exchange_handler_defaults.rb +61 -0
  19. data/lib/soaspec/exchange_handlers/handler_accessors.rb +2 -0
  20. data/lib/soaspec/exchange_handlers/request/rest_request.rb +3 -1
  21. data/lib/soaspec/exchange_handlers/request/soap_request.rb +3 -1
  22. data/lib/soaspec/exchange_handlers/response_extractor.rb +2 -0
  23. data/lib/soaspec/exchange_handlers/rest_exchanger_factory.rb +2 -0
  24. data/lib/soaspec/exchange_handlers/rest_handler.rb +8 -3
  25. data/lib/soaspec/exchange_handlers/rest_methods.rb +2 -0
  26. data/lib/soaspec/exchange_handlers/rest_parameters.rb +13 -0
  27. data/lib/soaspec/exchange_handlers/rest_parameters_defaults.rb +3 -1
  28. data/lib/soaspec/exchange_handlers/soap_handler.rb +4 -2
  29. data/lib/soaspec/exe_helpers.rb +2 -0
  30. data/lib/soaspec/generate_server.rb +2 -0
  31. data/lib/soaspec/indifferent_hash.rb +2 -0
  32. data/lib/soaspec/interpreter.rb +6 -4
  33. data/lib/soaspec/matchers.rb +6 -2
  34. data/lib/soaspec/o_auth2.rb +5 -3
  35. data/lib/soaspec/soaspec_shared_examples.rb +2 -0
  36. data/lib/soaspec/spec_logger.rb +2 -0
  37. data/lib/soaspec/template_reader.rb +2 -0
  38. data/lib/soaspec/test_server/get_bank.rb +2 -0
  39. data/lib/soaspec/test_server/id_manager.rb +2 -0
  40. data/lib/soaspec/test_server/invoices.rb +2 -0
  41. data/lib/soaspec/test_server/puppy_service.rb +2 -0
  42. data/lib/soaspec/test_server/test_attribute.rb +2 -0
  43. data/lib/soaspec/test_server/test_namespace.rb +2 -0
  44. data/lib/soaspec/version.rb +3 -1
  45. data/lib/soaspec/virtual_server.rb +2 -0
  46. data/lib/soaspec/wait.rb +3 -1
  47. data/lib/soaspec/wsdl_generator.rb +6 -6
  48. data/lib/soaspec.rb +2 -0
  49. data/soaspec.gemspec +2 -0
  50. data/test_wsdl.rb +2 -0
  51. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85321b628bfe9f5c96477fbbb8b630439332838b4552ce295c00486c94922461
4
- data.tar.gz: 9de5454ec0b65ee3442e6f3772d0f61d09463f1ba78751edfb9e9394331aaafb
3
+ metadata.gz: 13abdb0b785d580ec2af2397004bde32370cffa289fbafc7d754a51e2a2e7bee
4
+ data.tar.gz: 6825e3c29b77b9072e26b068b407f30e3ffcf2e97983fa1d78d47d2e79aedd2e
5
5
  SHA512:
6
- metadata.gz: 4a6b6e8b16a9c432ea9b8b23e90ec64e9174d96504c2c49089d0a732ddefe6d9d6b67b258dc143887314cf767ff3bd822b4c7a12baebc38824f72947823d9152
7
- data.tar.gz: d8cda71cffe34d1df8bae7fa0c701e6360009a70458e62eed88821cafd79ca25c47f6090f27821e4f1fc9c843741601e37ee3fa0e8c86ddcf73cc39680fe13ae
6
+ metadata.gz: '05649c438f5f8f9d43c870d9e0abc2dcf88fb8762c53374487e0dc7fdb33f4f422d8f6ef514ed536d8276b4705646a7fa471fbc9be4bc3875800c3b40a79c851'
7
+ data.tar.gz: ce3c53b92dadd7949b18455d835220961a4813954442ba5e46d789ae8f499dc114861f3a3f2d8e720cfda6b641d8c20995722978f36aa20a5c080963ce301958
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Version 0.2.30
2
+ * Enhancement
3
+ * New method `retry_on_exceptions` on `exchange_handler` where one can specify
4
+ exceptions to retry on for all exchanges using that Handler
5
+ * 'exception' method on handler that stores exception of last exchange
6
+
1
7
  Version 0.2.29
2
8
  * Enhancement
3
9
  * SpecLogger - change:
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  git_source(:gitlab) { |_repo_name| 'https://gitlab.com/samuel-garratt/soaspec' }
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'rake/clean'
@@ -12,7 +14,7 @@ RSpec::Core::RakeTask.new(spec: %i[clean clobber start_test_server]) do |t|
12
14
  t.pattern = "spec/**/#{ENV['folder']}*/#{ENV['test']}*_spec.rb"
13
15
  end
14
16
 
15
- task :parallel => [:clean, :clobber, :start_test_server] do
17
+ task parallel: %i[clean clobber start_test_server] do
16
18
  puts `parallel_rspec spec`
17
19
  end
18
20
 
data/exe/soaspec CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'thor'
4
5
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
data/exe/xml_to_yaml_file CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'xmlsimple'
4
5
  require 'yaml'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Override Hash class with convenience methods
2
4
  class Hash
3
5
  # Transform each key in Hash to a symbol. Privately used by non-self method
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/core_ext/string/inflections'
2
4
 
3
5
  # @return [Exchange] Return current or last exchange used in Cucumber
data/lib/soaspec/demo.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load this file for demoing Soaspec (e.g in IRB). Has common settings applicable for demoing
2
4
 
3
5
  require_relative '../soaspec'
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Soaspec
3
4
  # Standard Error related to Soaspec
4
- class Error < StandardError ; end
5
+ class Error < StandardError; end
5
6
  # Error related to a response
6
- class ResponseError < StandardError ; end
7
+ class ResponseError < StandardError; end
7
8
  end
8
9
 
9
10
  # Raised to represent when there's no element at an Xpath
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../soaspec'
2
4
  require_relative 'exchange_properties'
3
5
  require_relative 'exchange_extractor'
@@ -19,9 +21,11 @@ class Exchange
19
21
 
20
22
  # Instance of ExchangeHandler for which this exchange is made
21
23
  attr_accessor :exchange_handler
22
- # How many times to retry for a success
24
+ # @return [Integer] How many times to retry for a success
23
25
  attr_accessor :retry_count
24
- # Name used for displaying class
26
+ # @return [Integer] Times request was retried before being returned
27
+ attr_accessor :times_retried
28
+ # @@return [String] Name used for displaying class
25
29
  attr_accessor :test_name
26
30
  # Expect Factory to fail upon trying to create
27
31
  attr_writer :fail_factory
@@ -35,11 +39,18 @@ class Exchange
35
39
  self
36
40
  end
37
41
 
42
+ # This is set on an individual Exchange marking it as one that should be retried
38
43
  # @return [Bool] Whether to keep making request until success code reached
39
44
  def retry_for_success?
40
45
  @retry_for_success
41
46
  end
42
47
 
48
+ # Defined as general rule from ExchangeHandler
49
+ # @return [Boolean] Whether exception is an exception that must be retried
50
+ def invalid_exception?
51
+ !exchange_handler.retry_on_exceptions.find { |e| e == exchange_handler.exception.class }.nil?
52
+ end
53
+
43
54
  # Override this in subclass to tie that subclass to an ExchangeHandler
44
55
  # @return [Soaspec::ExchangeHandler] Soaspec::ExchangeHandler used by this exchange
45
56
  def default_handler_used; end
@@ -57,8 +68,8 @@ class Exchange
57
68
  @fail_factory = nil
58
69
  @override_parameters = override_parameters
59
70
  @retry_for_success = false
60
- self.retry_count = 3
61
- @exchange_handler.elements.each { |element| methods_for_element(element) }
71
+ self.retry_count = exchange_handler.retry_exception_limit
72
+ exchange_handler.elements.each { |element| methods_for_element(element) }
62
73
  end
63
74
 
64
75
  # @return [Hash] Hash representing what will be sent
@@ -74,10 +85,11 @@ class Exchange
74
85
  request_params = @override_parameters
75
86
  (0..retry_count).each do |count|
76
87
  response = exchange_handler.make_request(request_params)
77
- return response unless retry_for_success?
88
+ return response if !retry_for_success? && !invalid_exception?
78
89
  return response if (200..299).cover? exchange_handler.status_code_for(response)
79
90
 
80
- sleep 0.5 # Time before retrying
91
+ sleep exchange_handler.retry_pause_time # Time before retrying
92
+ self.times_retried = count
81
93
  break response if count == retry_count
82
94
  end
83
95
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Methods for extracting aspects of the traffic for a request / response
3
5
  # in an exchange from the ExchangeHandler that it's tied to
@@ -32,7 +34,7 @@ module Soaspec
32
34
  exchange_handler.value_from_path(response, path.to_s)
33
35
  end
34
36
 
35
- alias_method :value_from_path, :[]
37
+ alias value_from_path []
36
38
 
37
39
  # Using same path syntax as []. Returns true of false depending on whether an element is found
38
40
  # @return [Boolean] Whether an element exists at the path
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Convenience methods to set Exchange specific properties
3
5
  # Will be used when creating a subclass of Exchange
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Ways of repeating an exchange to reach a desired outcome
3
5
  module ExchangeRepeater
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Methods to help build a Request
3
5
  module RequestBuilder
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Enables Exchange to store and retrieve variables so that one
3
5
  # exchange can make assertions based on a previous one
@@ -1,10 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'handler_accessors'
4
+ require_relative 'exchange_handler_defaults'
2
5
 
3
6
  module Soaspec
4
7
  # Inherit this for a class describing how to implement a particular exchange.
5
- # Has basic methods common for methods defining RSpec tests in YAML
8
+ # Has methods common to Soaspec framework for working with Exchange/Handler pair
6
9
  class ExchangeHandler
7
10
  extend Soaspec::HandlerAccessors
11
+ include ExchangeHandlerDefaults
12
+
13
+ # @return [Exception] Exception if raised
14
+ attr_accessor :exception
8
15
 
9
16
  # Use an instance of this ExchangeHandler in any further Exchange's
10
17
  # This is a convenience method as it creates an ExchangeHandler behind the scenes
@@ -64,32 +71,6 @@ module Soaspec
64
71
  @template_name = name
65
72
  end
66
73
 
67
- # Will be used in 'success_scenarios' shared examples.
68
- # Set though 'mandatory_elements' method
69
- # @return [Array] Array of symbols specifying element names
70
- def expected_mandatory_elements
71
- []
72
- end
73
-
74
- # Change this through 'mandatory_xpath_values' method to specify xpath results that must be present in the response
75
- # Will be used in 'success_scenarios' shared examples
76
- # @return [Hash] Hash of 'xpath' => 'expected value' pairs
77
- def expected_mandatory_xpath_values
78
- {}
79
- end
80
-
81
- # Change this through 'mandatory_json_values' method to specify json results that must be present in the response
82
- # Will be used in 'success_scenarios' shared examples
83
- # @return [Hash] Hash of 'json/path' => 'expected value' pairs
84
- def expected_mandatory_json_values
85
- {}
86
- end
87
-
88
- # @return [Boolean] Whether all xpaths will be done with XML that is converted to lower case
89
- def convert_to_lower?
90
- false
91
- end
92
-
93
74
  # Stores a value in a method that can be accessed by the provided name
94
75
  # @param [Symbol] name Name of method to use to access this value within handler
95
76
  # @param [String] value Value to store
@@ -113,18 +94,5 @@ module Soaspec
113
94
  __send__("#{key}=", hash[key])
114
95
  hash.delete key
115
96
  end
116
-
117
- # @return [Boolean] Whether to remove namespaces in xpath assertion automatically
118
- def strip_namespaces?
119
- false
120
- end
121
-
122
- # Request of API call. Either intended request or actual request
123
- # @param [Object] response Response from calling exchange
124
- def request(response)
125
- return "Request not yet sent Request option is #{@request_option}" unless response
126
-
127
- 'Specific API handler should implement this'
128
- end
129
97
  end
130
98
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Default values set for methods on ExchangeHandler
4
+ module ExchangeHandlerDefaults
5
+ # Will be used in 'success_scenarios' shared examples.
6
+ # Set though 'mandatory_elements' method
7
+ # @return [Array] Array of symbols specifying element names
8
+ def expected_mandatory_elements
9
+ []
10
+ end
11
+
12
+ # Change this through 'mandatory_xpath_values' method to specify xpath results that must be present in the response
13
+ # Will be used in 'success_scenarios' shared examples
14
+ # @return [Hash] Hash of 'xpath' => 'expected value' pairs
15
+ def expected_mandatory_xpath_values
16
+ {}
17
+ end
18
+
19
+ # Change this through 'mandatory_json_values' method to specify json results that must be present in the response
20
+ # Will be used in 'success_scenarios' shared examples
21
+ # @return [Hash] Hash of 'json/path' => 'expected value' pairs
22
+ def expected_mandatory_json_values
23
+ {}
24
+ end
25
+
26
+ # @return [Boolean] Whether all xpaths will be done with XML that is converted to lower case
27
+ def convert_to_lower?
28
+ false
29
+ end
30
+
31
+ # @return [Boolean] Whether to remove namespaces in xpath assertion automatically
32
+ def strip_namespaces?
33
+ false
34
+ end
35
+
36
+ # Request of API call. Either intended request or actual request
37
+ # @param [Object] response Response from calling exchange
38
+ def request(response)
39
+ return "Request not yet sent Request option is #{@request_option}" unless response
40
+
41
+ 'Specific API handler should implement this'
42
+ end
43
+
44
+ # Set through 'retry_on_exceptions' method
45
+ # @return [Array] List of exceptions to retry for
46
+ def retry_on_exceptions
47
+ []
48
+ end
49
+
50
+ # Set this through 'retry_on_exceptions' on ExchangeHandler
51
+ # @return [Integer] Time to wait before retrying each request. Default of 1
52
+ def retry_pause_time
53
+ 1
54
+ end
55
+
56
+ # Set this through 'retry_on_exceptions' on ExchangeHandler
57
+ # @return [Integer] Times to retry before raising exception. Default of 3
58
+ def retry_exception_limit
59
+ 3
60
+ end
61
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Describes methods test handlers use to easily set attributes
3
5
  # Some are included in 'success scenarios' and to configure the request sent
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Models a request made to a REST API
3
5
  class RestRequest
@@ -38,7 +40,7 @@ module Soaspec
38
40
  # @param [String, Symbol] value Message to send to object retrieving a value
39
41
  # @return [Object] Result of retrieving value
40
42
  def [](value)
41
- self.send(value)
43
+ send(value)
42
44
  end
43
45
 
44
46
  # @return [String] Show inspection of all parameters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Models a request made to a SOAP API
3
5
  class SoapRequest
@@ -28,7 +30,7 @@ module Soaspec
28
30
  # @param [String, Symbol] value Message to send to object retrieving a value
29
31
  # @return [Object] Result of retrieving value
30
32
  def [](value)
31
- self.send(value)
33
+ send(value)
32
34
  end
33
35
 
34
36
  # @return [String] Show inspection of all parameters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Enables extracting a response according to type / path
3
5
  module ResponseExtractor
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Convenience methods for once off usage of a REST request
3
5
  module RestExchangeFactory
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'exchange_handler'
2
4
  require_relative 'rest_parameters'
3
5
  require_relative 'rest_parameters_defaults'
@@ -75,7 +77,7 @@ module Soaspec
75
77
  # Override this with 'after_response' within class definition to perform an action
76
78
  # after response is retrieved
77
79
  # @param [RestClient::Response] _response Response to interpret to perform after block
78
- def after_response(_response, _self) ; end
80
+ def after_response(_response, _self); end
79
81
 
80
82
  # Used in together with Exchange request that passes such override parameters
81
83
  # @param [Hash] override_parameters Params to characterize REST request
@@ -93,9 +95,9 @@ module Soaspec
93
95
  test_values = interpret_parameters override_parameters
94
96
  # In order for ERB to be calculated at correct time, the first time request is made, the resource should be created
95
97
  @resource ||= RestClient::Resource.new(ERB.new(base_url_value).result(binding), @merged_options)
96
-
97
98
  @resource_used = test_values[:suburl] ? @resource[test_values[:suburl]] : @resource
98
99
 
100
+ self.exception = nil # Remove any previously stored exception
99
101
  begin
100
102
  response = case test_values[:method]
101
103
  when :post, :patch, :put
@@ -104,7 +106,10 @@ module Soaspec
104
106
  else # :get, :delete
105
107
  @resource_used.send(test_values[:method].to_s, test_values[:params])
106
108
  end
107
- rescue RestClient::ExceptionWithResponse => e
109
+ rescue RestClient::Exception => e
110
+ self.exception = e
111
+ raise e unless e.respond_to? :response
112
+
108
113
  response = e.response
109
114
  end
110
115
  Soaspec::SpecLogger.info("response: \n headers: #{response&.headers}\n body: #{response}\n")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Contains commonly used REST methods. Include this module in the spec where you want to use it
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Methods to define parameters specific to REST handler
3
5
  module RestParameters
@@ -79,6 +81,17 @@ module Soaspec
79
81
  define_method('after_response') { |response, _self| yield response, self }
80
82
  end
81
83
 
84
+ # @param [Array] exception_list List of exceptions to retry response on. Default is
85
+ # any REST exception
86
+ # @param [Integer] pause Time to wait before retrying
87
+ # @param [Integer] count Times to retry
88
+ def retry_on_exceptions(exception_list = [RestClient::RestHandler], pause: 1,
89
+ count: 3)
90
+ define_method('retry_on_exceptions') { exception_list }
91
+ define_method('retry_pause_time') { pause }
92
+ define_method('retry_exception_limit') { count }
93
+ end
94
+
82
95
  private
83
96
 
84
97
  # Load credentials hash from a YAML using Soaspec.credentials_folder if set, adding '.yml' if not set
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Defaults for Soaspec RestParameters methods
3
5
  module RestParametersDefaults
@@ -19,7 +21,7 @@ module Soaspec
19
21
  # base_url "#{parent_url}/child_path"
20
22
  # end
21
23
  #
22
- # Child.new.base_url_value #=> 'parent/child_path'
24
+ # Child.new.base_url_value # => 'parent/child_path'
23
25
  # @return [String] Base url that can be accessed by a subclass.
24
26
  def parent_url
25
27
  raise 'This needs to be set through base_url method'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'exchange_handler'
2
4
  require_relative '../core_ext/hash'
3
5
  require_relative '../errors'
@@ -107,8 +109,8 @@ module Soaspec
107
109
  # Call the SOAP operation with the request XML provided
108
110
  request = request_parameters(request_parameters)
109
111
  begin
110
- client.call request.operation, request.body #request_body_params(request_parameters)
111
- rescue Savon::HTTPError => soap_error
112
+ client.call request.operation, request.body # request_body_params(request_parameters)
113
+ rescue Savon::HTTPError => e
112
114
  soap_error
113
115
  end
114
116
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
  module Soaspec
3
5
  # Help with tasks common to soaspec executables
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sinatra'
2
4
 
3
5
  module Soaspec
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'hashie'
2
4
 
3
5
  # Hash that allows accessing hash with either string or Hash
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Help interpret the general type of a particular object
2
4
  class Interpreter
3
5
  class << self
@@ -52,16 +54,16 @@ class Interpreter
52
54
  # @return [Boolean] Whether valid XML
53
55
  def xml?
54
56
  Nokogiri::XML(@response) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
55
- rescue Nokogiri::XML::SyntaxError => xml_error
56
- self.xml_errors = xml_error
57
+ rescue Nokogiri::XML::SyntaxError => e
58
+ self.xml_errors = e
57
59
  false
58
60
  end
59
61
 
60
62
  # @return [Boolean] Whether valid JSON
61
63
  def json?
62
64
  JSON.parse(@response)
63
- rescue JSON::ParserError=> json_error
64
- self.json_errors = json_error
65
+ rescue JSON::ParserError => e
66
+ self.json_errors = e
65
67
  false
66
68
  end
67
69
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'core_ext/hash'
2
4
  require_relative 'errors'
3
5
 
@@ -85,8 +87,8 @@ RSpec::Matchers.define :be_successful do
85
87
  exchange.exchange_handler.expected_mandatory_elements.each do |mandatory_element_path|
86
88
  begin
87
89
  exchange[mandatory_element_path]
88
- rescue NoElementAtPath => error
89
- failure_list << error.message
90
+ rescue NoElementAtPath => e
91
+ failure_list << e.message
90
92
  end
91
93
  end
92
94
  exchange.exchange_handler.expected_mandatory_xpath_values.each do |path, value|
@@ -102,6 +104,7 @@ RSpec::Matchers.define :be_successful do
102
104
  exchange = exchange_from actual
103
105
  failure_list = collect_errors exchange
104
106
  raise failure_list.to_s unless failure_list.empty?
107
+
105
108
  true
106
109
  end
107
110
 
@@ -109,6 +112,7 @@ RSpec::Matchers.define :be_successful do
109
112
  exchange = exchange_from actual
110
113
  failure_list = collect_errors exchange
111
114
  raise "Expected failure. Status code is #{exchange.status_code}" if failure_list.empty?
115
+
112
116
  true
113
117
  end
114
118
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'erb'
2
4
 
3
5
  module Soaspec
@@ -98,12 +100,12 @@ module Soaspec
98
100
  def response
99
101
  Soaspec::SpecLogger.info "using oauth_params: #{params}" if debug_oauth?
100
102
  response = RestClient.post(params[:token_url], payload, cache_control: 'no_cache', verify_ssl: false)
101
- rescue RestClient::Exception => error
102
- Soaspec::SpecLogger.info(["oauth_error: #{error.message}", "oauth_response: #{error.response}"])
103
+ rescue RestClient::Exception => e
104
+ Soaspec::SpecLogger.info(["oauth_error: #{e.message}", "oauth_response: #{e.response}"])
103
105
  self.retry_count += 1
104
106
  sleep 0.1 # Wait if a bit before retying obtaining access token
105
107
  retry if retry_count < self.class.retry_limit
106
- raise error
108
+ raise e
107
109
  else
108
110
  Soaspec::SpecLogger.info(["response: \n headers: #{response&.headers}\n body: #{response}\n"]) if debug_oauth?
109
111
  JSON.parse(response)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec'
2
4
 
3
5
  RSpec.shared_examples_for 'success scenario' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
  require 'fileutils'
3
5
  require 'colorize'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'erb'
2
4
 
3
5
  module Soaspec
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'erb'
2
4
 
3
5
  module Soaspec
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  module TestServer
3
5
  # Handles returning ids dependent on a number of factors
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  module TestServer
3
5
  # Used to simulate requests requiring oauth authentication
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  module TestServer
3
5
  # Simulates ordering a new puppy. Used for testing REST storing, retrieving and updating data
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  module TestServer
3
5
  # Helps tests attribute methods
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  module TestServer
3
5
  # Helps tests attribute methods
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # @return [String] Version of the gem
3
- VERSION = '0.2.29'.freeze
5
+ VERSION = '0.2.30'
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'soaspec'
2
4
  require 'sinatra'
3
5
  require 'sinatra/basic_auth'
data/lib/soaspec/wait.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  class TimeOutError < StandardError; end
3
5
  # Class to enable waiting for an expected condition to return true
@@ -27,7 +29,7 @@ module Soaspec
27
29
  begin
28
30
  result = yield
29
31
  return result if result
30
- rescue *ignored => last_error
32
+ rescue *ignored => e
31
33
  # swallowed
32
34
  end
33
35
  sleep interval
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Soaspec
2
4
  # Produce test content from a WSDL
3
5
  module WsdlGenerator
@@ -26,12 +28,10 @@ module Soaspec
26
28
  @use_camel_case = false
27
29
  puts 'Message params: ' + op_details.to_s
28
30
  # From namespace identifier, find namespace, and for that find schemaLocation xsd and use that to build request
29
- if op_details[:parameters]
30
- op_details[:parameters].each do |element, details|
31
- @use_camel_case = true unless /[[:upper:]]/.match(element.to_s[0]).nil?
32
- @content += " #{element.to_s.snakecase}: #{fill_in_field_from_type(details[:type])} # #{details[:type]} \n"
33
- # TODO: If details is a Hash need to loop again
34
- end
31
+ op_details[:parameters]&.each do |element, details|
32
+ @use_camel_case = true unless /[[:upper:]]/.match(element.to_s[0]).nil?
33
+ @content += " #{element.to_s.snakecase}: #{fill_in_field_from_type(details[:type])} # #{details[:type]} \n"
34
+ # TODO: If details is a Hash need to loop again
35
35
  end
36
36
  wsdl_to_yaml_for root_elements_for(op_details)
37
37
  params = []
data/lib/soaspec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rest-client' # REST
2
4
  require 'erb' # Embedded ruby
3
5
  require 'yaml' # Reading yaml
data/soaspec.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'soaspec/version'
data/test_wsdl.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'wasabi'
2
4
  require 'savon'
3
5
 
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.2.29
4
+ version: 0.2.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -481,6 +481,7 @@ files:
481
481
  - lib/soaspec/exchange/request_builder.rb
482
482
  - lib/soaspec/exchange/variable_storer.rb
483
483
  - lib/soaspec/exchange_handlers/exchange_handler.rb
484
+ - lib/soaspec/exchange_handlers/exchange_handler_defaults.rb
484
485
  - lib/soaspec/exchange_handlers/handler_accessors.rb
485
486
  - lib/soaspec/exchange_handlers/request/rest_request.rb
486
487
  - lib/soaspec/exchange_handlers/request/soap_request.rb