soaspec 0.2.3 → 0.2.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fc08897eb83281f6c6226c6f0df1768129ec307
|
4
|
+
data.tar.gz: 58e5b2672c36a667471f97159e63dea73ca44dbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 603ad5943c9f9e063163ab0cf485af270f0a91639a0c7a4535a9e2aeae757fac9d9ad442b14d039ece23316827e3be39ee3c53532a1cdc148d6526b37e9adc1b
|
7
|
+
data.tar.gz: 03312d09ccada29afa1c5d61a8a1a559287cdd35f96289b53490f25f22d3d07e44368e14824bfdd8ef5dce579de0f4ec2d64e7a76dadc8dfc50cfdfc1bf823d0
|
data/ChangeLog
CHANGED
@@ -12,7 +12,7 @@ module Soaspec
|
|
12
12
|
# @option override_parameters [String] :template_name Path to file to be read via ERB and passed in request body
|
13
13
|
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
14
14
|
def post(params = {})
|
15
|
-
|
15
|
+
perform_exchange_with(:post, params)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Make REST Exchange with 'patch' method within this Handler context
|
@@ -26,7 +26,7 @@ module Soaspec
|
|
26
26
|
# @option override_parameters [String] :template_name Path to file to be read via ERB and passed in request body
|
27
27
|
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
28
28
|
def patch(params)
|
29
|
-
|
29
|
+
perform_exchange_with(:patch, params)
|
30
30
|
end
|
31
31
|
|
32
32
|
# Make REST Exchange with 'put' method within this Handler context
|
@@ -40,7 +40,7 @@ module Soaspec
|
|
40
40
|
# @option override_parameters [String] :template_name Path to file to be read via ERB and passed in request body
|
41
41
|
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
42
42
|
def put(params = {})
|
43
|
-
|
43
|
+
perform_exchange_with(:put, params)
|
44
44
|
end
|
45
45
|
|
46
46
|
# Make REST Exchange with 'get' method within this Handler context.
|
@@ -55,7 +55,7 @@ module Soaspec
|
|
55
55
|
# @option override_parameters [String] :template_name Path to file to be read via ERB and passed in request body
|
56
56
|
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
57
57
|
def get(params = {})
|
58
|
-
|
58
|
+
perform_exchange_with(:get, params)
|
59
59
|
end
|
60
60
|
|
61
61
|
# Make REST Exchange with 'delete' method within this Handler context.
|
@@ -70,34 +70,42 @@ module Soaspec
|
|
70
70
|
# @option override_parameters [String] :template_name Path to file to be read via ERB and passed in request body
|
71
71
|
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
72
72
|
def delete(params = {})
|
73
|
-
|
73
|
+
perform_exchange_with(:delete, params)
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
private
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
78
|
+
# Make REST Exchange within this Handler context
|
79
|
+
# @param [Symbol] rest_method HTTP rest method to use
|
80
|
+
# @param [Hash, String] params Exchange parameters.
|
81
|
+
# @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
|
82
|
+
def perform_exchange_with(rest_method, params = {})
|
83
|
+
params = determine_params_for(rest_method, params)
|
84
|
+
params[:name] ||= rest_method.to_s
|
85
|
+
exchange_params = { name: params[:name] }
|
86
|
+
if params[:template_name]
|
87
|
+
exchange_params[:template_name] = params[:template_name]
|
88
|
+
params.delete :template_name
|
89
|
+
end
|
90
|
+
new(exchange_params)
|
91
|
+
exchange = Exchange.new(params[:name], method: rest_method, **params)
|
92
|
+
yield exchange if block_given?
|
93
|
+
exchange
|
94
|
+
end
|
95
|
+
|
96
|
+
# @param [Symbol] method HTTP rest method to use
|
97
|
+
# @param [Hash, String] params Exchange parameters.
|
98
|
+
# @return [Hash] Exchange Parameters after setting shorthand parameters
|
99
|
+
def determine_params_for(method, params)
|
100
|
+
return params if params.is_a? Hash
|
101
|
+
|
102
|
+
case method
|
103
|
+
when :get, :delete
|
104
|
+
{ suburl: params.to_s }
|
105
|
+
when :post, :put, :patch
|
106
|
+
{ payload: params.to_s }
|
107
|
+
else
|
108
|
+
raise "'#{params}' needs to be a 'Hash' but is a #{params.class}"
|
101
109
|
end
|
102
110
|
end
|
103
111
|
end
|
data/lib/soaspec/matchers.rb
CHANGED
@@ -26,7 +26,9 @@ end
|
|
26
26
|
|
27
27
|
# Whether an element exists at expected xpath
|
28
28
|
RSpec::Matchers.define :have_element_at_path do |xpath|
|
29
|
-
match do |
|
29
|
+
match do |object|
|
30
|
+
# Object like `response` returns the Exchange object from which a path can be obtained
|
31
|
+
exchange = object.respond_to?(:exchange) ? object.exchange : object
|
30
32
|
expect { exchange[xpath] }.to_not raise_error # Error will be raised if Path returns no value
|
31
33
|
end
|
32
34
|
|
@@ -42,7 +44,9 @@ RSpec::Matchers.alias_matcher :contain_key, :have_element_at_path
|
|
42
44
|
# Whether an element at xpath (defined by key) has value (defined by value).
|
43
45
|
# @param [Hash] expected_hash Xpath => Value pair (e.g. '//xmlns:GetWeatherResult' => 'Data Not Found')
|
44
46
|
RSpec::Matchers.define :have_xpath_value do |expected_hash|
|
45
|
-
match do |
|
47
|
+
match do |object|
|
48
|
+
# Object like `response` returns the Exchange object from which a path can be obtained
|
49
|
+
exchange = object.respond_to?(:exchange) ? object.exchange : object
|
46
50
|
expected_hash = Hash[*expected_hash.flatten] if expected_hash.is_a?(Array) # For some reason Array was occuring
|
47
51
|
expect(exchange[expected_hash.keys.first]).to eq expected_hash.values.first
|
48
52
|
end
|
@@ -50,9 +54,10 @@ RSpec::Matchers.define :have_xpath_value do |expected_hash|
|
|
50
54
|
failure_message do |actual|
|
51
55
|
"expected that xpath '#{expected_hash.keys.first}' has value '#{expected_hash.values.first}' but was '#{actual[expected_hash.keys.first]}'"
|
52
56
|
end
|
53
|
-
|
54
57
|
end
|
55
58
|
|
59
|
+
RSpec::Matchers.alias_matcher :have_jsonpath_value, :have_xpath_value
|
60
|
+
|
56
61
|
RSpec::Matchers.define :be_found do
|
57
62
|
|
58
63
|
match do |exchange|
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|