soaspec 0.2.25 → 0.2.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e05f737b159b34765390c9e79d2fa63c3f38224
4
- data.tar.gz: b0b6698390955dd891e546e8d23a73b06aa5a494
3
+ metadata.gz: 4bd3c881794d21629f39071352bc0e9c49eba252
4
+ data.tar.gz: 919b6649e0b29f590f388bb78af1b9f34d6d8613
5
5
  SHA512:
6
- metadata.gz: 565dd25349cb90c5c15064a0040f3ce503c74e1f522f42c0329dc8cd02ba1ae5c7a64321711438ad6c09418428606a6c8ef76fad8c5a114f3a88625f0eaed198
7
- data.tar.gz: 41c2cc405ee6a1fc8e86929cd00a91b30ce2f9abcd71caa4fc3b024ce3d157c43d99e2b58ba701a96e572f71d520a3b49c2df78341d9dbe16d9ffa609851ccec
6
+ metadata.gz: 0c95b0a30c4efbc31b369cb3735d4676ff7c5cabe1577f065b66dc9b427010d2c4b5c4b2370e7db2f67574bb907feb6d03109275c33b5a9ade6158f7ec51c2a3
7
+ data.tar.gz: ef8f3c18d7e64ecc1953c73463373ca26ce22f2b8fcf7ca70a4f3d51f08606cd5cfb82f235dd578d7d30e5971f5e3c1816d0bed96654bc089408a70c3c581e9b
data/.gitignore CHANGED
@@ -9,7 +9,7 @@
9
9
  /tmp/
10
10
  /.idea/
11
11
  Gemfile.lock
12
- coverage
12
+ /vendor/
13
13
 
14
14
  # rspec failure tracking
15
15
  .rspec_status
data/.gitlab-ci.yml CHANGED
@@ -4,29 +4,40 @@ before_script:
4
4
  - ruby -v
5
5
  - which ruby
6
6
  - gem install bundler rake
7
- - bundle install --jobs $(nproc) "${FLAGS[@]}"
7
+ - bundle install --jobs $(nproc) --path vendor # Install dependencies into ./vendor/ruby
8
+
9
+ cache:
10
+ key: ${CI_COMMIT_REF_SLUG}
11
+ paths:
12
+ - vendor/ruby
8
13
 
9
14
  ruby_2.3:
10
15
  stage: test
11
16
  image: ruby:2.3
12
17
  script:
13
- - bundle exec rake spec
18
+ - bundle exec rake
14
19
 
15
20
  ruby_2.4:
16
21
  stage: test
17
22
  image: ruby:2.4
18
23
  script:
19
- - bundle exec rake spec
24
+ - bundle exec rake
20
25
 
21
26
  ruby_2.5:
22
27
  stage: test
23
28
  image: ruby:2.5
24
29
  script:
25
- - bundle exec rake spec
30
+ - bundle exec rake
26
31
  artifacts:
27
32
  paths:
28
33
  - coverage/
29
34
 
35
+ ruby_2.6:
36
+ stage: test
37
+ image: ruby:2.6
38
+ script:
39
+ - bundle exec rake
40
+
30
41
  cucumber:
31
42
  stage: test
32
43
  script:
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.2.26
2
+ * Enhancement
3
+ * Method `successful_status_code?` to return whether status code is 200..299
4
+ * Ability to turn off OAuth request message
5
+
1
6
  Version 0.2.25
2
7
  * Enhancement
3
8
  * Started running yard-doctest to check yard examples are correct
data/Dockerfile ADDED
@@ -0,0 +1,5 @@
1
+ FROM ruby:2.6
2
+ MAINTAINER Samuel Garratt
3
+ LABEL url="https://gitlab.com/samuel-garratt/soaspec/blob/master/Dockerfile"
4
+ # Simple Dockerfile with gems preinstalled
5
+ RUN gem install bundler rake soaspec
data/Todo.md CHANGED
@@ -1,3 +1,4 @@
1
+ * Exception in setting a value results in 'headers' being called on Nil Class
1
2
  * `yard` should show everything documented
2
3
  * Rubocop should have 0 offenses
3
4
  * Unit tests
@@ -14,6 +14,11 @@ module Soaspec
14
14
  exchange_handler.status_code_for(response)
15
15
  end
16
16
 
17
+ # @return [Boolean] Whether Api success code is successful
18
+ def successful_status_code?
19
+ (200..299).cover? status_code
20
+ end
21
+
17
22
  # Extract value from path api class
18
23
  # @example Extract unique value
19
24
  # @exchange['unique_value_name']
@@ -7,7 +7,7 @@ module Soaspec
7
7
  # @option opts [Numeric] :interval (0.2) Seconds to sleep between polls.
8
8
  # @option opts [String] :message Exception message if timed out.
9
9
  # @option opts [Array, Exception] :ignore Exceptions to ignore while polling (default: Error::NoSuchElementError)
10
- # @return [Self] Returns itself so operations can be done on the exchange after it's done waiting
10
+ # @return [Exchange] Returns itself so operations can be done on the exchange after it's done waiting
11
11
  def until(opts = {}, &script)
12
12
  Soaspec::Wait.until(opts) do
13
13
  @response = nil # Reset response so it can be made repeatedly
@@ -28,7 +28,7 @@ module Soaspec
28
28
  when :json
29
29
  IndifferentHash.new(JSON.parse(response.body.to_s))
30
30
  else
31
- raise "Unable to interpret type of #{response.body}"
31
+ raise "Unable to interpret type of '#{response.body}'. Could be because of: #{Interpreter.diagnose_error}"
32
32
  end
33
33
  end
34
34
 
@@ -1,9 +1,17 @@
1
1
  # Help interpret the general type of a particular object
2
2
  class Interpreter
3
3
  class << self
4
+ # @return [Error] XML Errors found in interpreting response
5
+ attr_accessor :xml_errors
6
+
7
+ # @return [Error] JSON Errors found in interpreting response
8
+ attr_accessor :json_errors
9
+
4
10
  # @param [Object] response API response
5
11
  # @return [Symbol] Type of provided response
6
12
  def response_type_for(response)
13
+ @xml_errors = nil
14
+ @json_errors = nil
7
15
  @response = response
8
16
  if @response.is_a? String
9
17
  if xml?
@@ -22,17 +30,38 @@ class Interpreter
22
30
  end
23
31
  end
24
32
 
33
+ # @return [Boolean] Whether response has tag like syntax similar to XML. Could be a syntax error occurred
34
+ def looks_like_xml?
35
+ @response[0] == '<' && @response[-1] == '>'
36
+ end
37
+
38
+ # @return [Boolean] Whether response has bracket like syntax similar to JSON. Could be a syntax error occurred
39
+ def looks_like_json?
40
+ @response[0] == '{' && @response[-1] == '}'
41
+ end
42
+
43
+ # @return [String] Description of error
44
+ def diagnose_error
45
+ return xml_errors if looks_like_xml?
46
+
47
+ return json_errors if looks_like_json?
48
+
49
+ ''
50
+ end
51
+
25
52
  # @return [Boolean] Whether valid XML
26
53
  def xml?
27
54
  Nokogiri::XML(@response) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
28
- rescue Nokogiri::XML::SyntaxError
55
+ rescue Nokogiri::XML::SyntaxError => xml_error
56
+ self.xml_errors = xml_error
29
57
  false
30
58
  end
31
59
 
32
60
  # @return [Boolean] Whether valid JSON
33
61
  def json?
34
62
  JSON.parse(@response)
35
- rescue JSON::ParserError
63
+ rescue JSON::ParserError=> json_error
64
+ self.json_errors = json_error
36
65
  false
37
66
  end
38
67
  end
@@ -81,7 +81,7 @@ RSpec::Matchers.define :be_successful do
81
81
  # @return [Array] List of errors when checking Exchange response is successful
82
82
  def collect_errors(exchange)
83
83
  failure_list = []
84
- failure_list << "#{exchange.status_code} not valid status code" unless (200..299).cover?(exchange.status_code)
84
+ failure_list << "#{exchange.status_code} not valid status code" unless exchange.successful_status_code?
85
85
  exchange.exchange_handler.expected_mandatory_elements.each do |mandatory_element_path|
86
86
  begin
87
87
  exchange[mandatory_element_path]
@@ -9,6 +9,8 @@ module Soaspec
9
9
  @access_tokens = {}
10
10
  # List of instance URLs. They are mapped according to the OAuth parameters used
11
11
  @instance_urls = {}
12
+ # Whether to see params sent to & received from oauth URL
13
+ @request_message = true
12
14
  class << self
13
15
  # Default token url used across entire suite
14
16
  attr_accessor :token_url
@@ -23,11 +25,18 @@ module Soaspec
23
25
  attr_accessor :instance_urls
24
26
  # Specify whether to see params sent to and retrieved from oauth. This will put password in log file, only recommended for debugging
25
27
  attr_writer :debug_oauth
28
+ # @return [Boolean] Whether to include request message describing OAuth (either full or simplified)
29
+ attr_writer :request_message
26
30
 
27
31
  # @return [Boolean] Whether to see params sent to & received from oauth URL
28
32
  def debug_oauth?
29
33
  @debug_oauth || false
30
34
  end
35
+
36
+ # @return [Boolean] Whether to include request message describing OAuth (either full or simplified)
37
+ def request_message?
38
+ @request_message
39
+ end
31
40
  end
32
41
 
33
42
  # @attr [Hash] OAuth parameters
@@ -73,7 +82,7 @@ module Soaspec
73
82
 
74
83
  # @return [String] Existing or new access token, dependent on refresh_token attribute
75
84
  def access_token
76
- Soaspec::SpecLogger.info request_message
85
+ Soaspec::SpecLogger.info request_message if self.class.request_message?
77
86
  case Soaspec::OAuth2.refresh_token
78
87
  when :once
79
88
  Soaspec::OAuth2.access_tokens[params] ||= response['access_token']
@@ -2,7 +2,7 @@ require 'rspec'
2
2
 
3
3
  RSpec.shared_examples_for 'success scenario' do
4
4
  it 'has successful status code' do
5
- expect(200..299).to cover described_class.status_code
5
+ expect(described_class.successful_status_code?).to be true
6
6
  end
7
7
  context 'has expected mandatory elements' do
8
8
  described_class.exchange_handler.expected_mandatory_elements.each do |mandatory_element|
@@ -1,4 +1,4 @@
1
1
  module Soaspec
2
2
  # @return [String] Version of the gem
3
- VERSION = '0.2.25'.freeze
3
+ VERSION = '0.2.26'.freeze
4
4
  end
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.25
4
+ version: 0.2.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-30 00:00:00.000000000 Z
11
+ date: 2019-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -461,6 +461,7 @@ files:
461
461
  - ".rubocop.yml"
462
462
  - CODE_OF_CONDUCT.md
463
463
  - ChangeLog
464
+ - Dockerfile
464
465
  - Gemfile
465
466
  - LICENSE.txt
466
467
  - README.md