soaspec 0.0.34 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/Gemfile.lock +1 -1
- data/lib/soaspec.rb +16 -0
- data/lib/soaspec/accessors.rb +10 -0
- data/lib/soaspec/exchange_handlers/rest_handler.rb +5 -2
- data/lib/soaspec/exchange_handlers/soap_handler.rb +1 -1
- data/lib/soaspec/hash_methods.rb +10 -1
- data/lib/soaspec/interpreter.rb +1 -1
- data/lib/soaspec/matchers.rb +4 -2
- 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: 4c7df2a27ca4097085513de2d9afa7d45e8eb9ff
|
4
|
+
data.tar.gz: 691d473c89b69df0dbb5fcb21ffdfe13c67dd236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5a1e6b75df8eca6e4b03ac1e654e0d649c92dcbb72af84852115f5cdf3b8427697fdaf8a1aff779398c9d993e8734eeb4b0b2340a7e59e2956b15fd1178935
|
7
|
+
data.tar.gz: 38e3753dfaf0f7eeb859601777a3158019fa84cb5e0e1497b03cccc3143f6fd8b3f2b09ad0cce493c52fc46ff120d60ec0c319077747ec08e938d8e90a8fe4e4
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.35 / 2018-3-13
|
2
|
+
* Enhancements
|
3
|
+
* Handle array of JSON hashes starting with '['
|
4
|
+
* Handle patch and put methods with data for REST
|
5
|
+
|
1
6
|
Version 0.0.34 / 2018-3-12
|
2
7
|
* Enhancements
|
3
8
|
* Add oauth2 and oauth2_file methods to make it easy to load oauth2 parameters. Still a work in progress to handle all oauth2 variations
|
data/Gemfile.lock
CHANGED
data/lib/soaspec.rb
CHANGED
@@ -83,6 +83,22 @@ module Soaspec
|
|
83
83
|
Exchange.new(name, method: :post, **params)
|
84
84
|
end
|
85
85
|
|
86
|
+
# Make REST Patch Exchange
|
87
|
+
# @param [String] name Name of test displayed
|
88
|
+
# @param [Hash] params Exchange parameters
|
89
|
+
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
90
|
+
def patch(name, params = {})
|
91
|
+
Exchange.new(name, method: :patch, **params)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Make REST Put Exchange
|
95
|
+
# @param [String] name Name of test displayed
|
96
|
+
# @param [Hash] params Exchange parameters
|
97
|
+
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
98
|
+
def put(name, params = {})
|
99
|
+
Exchange.new(name, method: :put, **params)
|
100
|
+
end
|
101
|
+
|
86
102
|
# Make REST Get Exchange
|
87
103
|
# @param [String] name Name of test displayed
|
88
104
|
# @param [Hash] params Exchange parameters
|
data/lib/soaspec/accessors.rb
CHANGED
@@ -12,6 +12,16 @@ module Soaspec
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
# Defines mandatory xpaths value pairs to be included in 'success scenario' shared example
|
16
|
+
#
|
17
|
+
# @example Inside class
|
18
|
+
# mandatory_xpath_values '//xmlns:GetWeatherResult' => 'Data Not Found'
|
19
|
+
#
|
20
|
+
# In test
|
21
|
+
# describe Exchange(:name) do
|
22
|
+
# it_behaves_like 'success scenario' # Includes xpath pair validation
|
23
|
+
# end
|
24
|
+
#
|
15
25
|
def mandatory_xpath_values(xpath_value_pairs)
|
16
26
|
raise ArgumentError('Hash of {xpath => expected values} expected ') unless xpath_value_pairs.is_a? Hash
|
17
27
|
define_method('expected_mandatory_xpath_values') do
|
@@ -113,7 +113,7 @@ module Soaspec
|
|
113
113
|
|
114
114
|
begin
|
115
115
|
response = case test_values[:method]
|
116
|
-
when :post
|
116
|
+
when :post, :patch, :put
|
117
117
|
unless test_values[:payload]
|
118
118
|
test_values[:payload] = JSON.generate(test_values[:body]).to_s if test_values[:body]
|
119
119
|
end
|
@@ -150,7 +150,10 @@ module Soaspec
|
|
150
150
|
raise ArgumentError("Empty Body. Can't assert on it") if response.body.empty?
|
151
151
|
case Interpreter.response_type_for response
|
152
152
|
when :json
|
153
|
-
JSON.parse(response.body)
|
153
|
+
converted = JSON.parse(response.body)
|
154
|
+
return converted.transform_keys_to_symbols if converted.is_a? Hash
|
155
|
+
return converted.map!(&:transform_keys_to_symbols) if converted.is_a? Array
|
156
|
+
raise 'Incorrect Type prodcued ' + converted.class
|
154
157
|
when :xml
|
155
158
|
parser = Nori.new(convert_tags_to: lambda { |tag| tag.snakecase.to_sym })
|
156
159
|
parser.parse(response.body)
|
data/lib/soaspec/hash_methods.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
|
2
|
+
|
3
|
+
|
2
4
|
# Override Hash class with convience methods
|
3
5
|
class Hash
|
4
6
|
|
@@ -76,4 +78,11 @@ class Hash
|
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
79
|
-
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class Array
|
84
|
+
# Call include key on 1st element of array
|
85
|
+
def include_key?(key)
|
86
|
+
first.include_key? key
|
87
|
+
end
|
88
|
+
end
|
data/lib/soaspec/interpreter.rb
CHANGED
data/lib/soaspec/matchers.rb
CHANGED
@@ -22,7 +22,7 @@ RSpec::Matchers.define :include_in_body do |expected|
|
|
22
22
|
end
|
23
23
|
|
24
24
|
failure_message do |actual|
|
25
|
-
"expected that #{actual.api_class.response_body(actual.response, format: :
|
25
|
+
"expected that #{actual.api_class.response_body(actual.response, format: :raw)} would contain value #{expected}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -44,10 +44,12 @@ RSpec::Matchers.define :have_element_at_xpath do |xpath|
|
|
44
44
|
end
|
45
45
|
|
46
46
|
failure_message do |actual|
|
47
|
-
"expected that #{actual.api_class.response_body(actual.response, format: :
|
47
|
+
"expected that #{actual.api_class.response_body(actual.response, format: :raw)} would have element at xpath '#{xpath}'"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
RSpec::Matchers.alias_matcher :have_element_at_path, :have_element_at_xpath
|
52
|
+
|
51
53
|
# Whether an element at xpath (defined by key) has value (defined by value).
|
52
54
|
# @param [Hash] expected_hash Xpath => Value pair (e.g. '//xmlns:GetWeatherResult' => 'Data Not Found')
|
53
55
|
RSpec::Matchers.define :have_xpath_value do |expected_hash|
|
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.35
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|