soaspec 0.0.27 → 0.0.28
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 +4 -4
- data/ChangeLog +5 -0
- data/Gemfile.lock +1 -1
- data/config/data/default.yml +1 -1
- data/lib/soaspec/exchange.rb +3 -4
- data/lib/soaspec/matchers.rb +14 -0
- data/lib/soaspec/rest_handler.rb +9 -0
- data/lib/soaspec/version.rb +1 -1
- metadata +2 -3
- data/test.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18f0661c8b343eccfa911819e895b4a971f18e91
|
4
|
+
data.tar.gz: 6b9f9aa4d5a318efa2c0c71962fbc93ec3198dcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4ec79ab87e48032d3a142f7643484d7731b33d36d2d10d6a7640668ead69107c0e5032c7a8a5bdc87e65dad3948b9a0c9c3a773ab78baf7c639cee0e1582ad0
|
7
|
+
data.tar.gz: ab95079660cf8df4190137987b15b31bb0cbd0906ca8c44a28fc843fca6e921dfb01988e3f4bcbad02dfa9a79fd3975f4b9955aab52f64aa782dc320b1f27bd3
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.28 / 2018-3-6
|
2
|
+
* Enhancements
|
3
|
+
* Added not_found matcher and used in spec example
|
4
|
+
* Only call request upon first need of an Exchange response. This means test request is made as part of 'it' rather than in describe
|
5
|
+
|
1
6
|
Version 0.0.27 / 2018-3-5
|
2
7
|
* Bug fix
|
3
8
|
* Fixed log file not present error
|
data/Gemfile.lock
CHANGED
data/config/data/default.yml
CHANGED
data/lib/soaspec/exchange.rb
CHANGED
@@ -21,22 +21,21 @@ class Exchange
|
|
21
21
|
# @return [String] Name given when initializing
|
22
22
|
def to_s
|
23
23
|
Soaspec::SpecLogger.add_to 'Example ' + @test_name
|
24
|
-
@response = make_request
|
25
24
|
@test_name
|
26
25
|
end
|
27
26
|
|
28
|
-
# Returns response object from Api
|
27
|
+
# Returns response object from Api. Will make the request if not made and then cache it for later on
|
29
28
|
# For example for SOAP it will be a Savon response
|
30
29
|
# response.body (body of response as Hash)
|
31
30
|
# response.header (head of response as Hash)
|
32
31
|
def response
|
33
|
-
@response
|
32
|
+
@response ||= make_request
|
34
33
|
end
|
35
34
|
|
36
35
|
# Get status code from api class. This is http response for Web Api
|
37
36
|
# @return [Integer] Status code from api class
|
38
37
|
def status_code
|
39
|
-
@api_class.status_code_for(
|
38
|
+
@api_class.status_code_for(self.response)
|
40
39
|
end
|
41
40
|
|
42
41
|
# Extract value from path api class
|
data/lib/soaspec/matchers.rb
CHANGED
@@ -10,6 +10,7 @@ RSpec::Matchers.define :contain_value do |expected|
|
|
10
10
|
expect(actual.api_class.include_value?(actual.response, expected)).to be true
|
11
11
|
end
|
12
12
|
|
13
|
+
# TODO: Fix this for REST
|
13
14
|
failure_message do |actual|
|
14
15
|
"expected that #{actual.response.body} would contain value #{expected}"
|
15
16
|
end
|
@@ -21,6 +22,7 @@ RSpec::Matchers.define :include_in_body do |expected|
|
|
21
22
|
expect(actual.api_class.include_in_body?(actual.response, expected)).to be true
|
22
23
|
end
|
23
24
|
|
25
|
+
# TODO: Fix this for REST
|
24
26
|
failure_message do |actual|
|
25
27
|
"expected that #{actual.response.body.to_xml} would contain value #{expected}"
|
26
28
|
end
|
@@ -60,4 +62,16 @@ RSpec::Matchers.define :have_xpath_value do |expected_hash|
|
|
60
62
|
"expected that xpath '#{expected_hash.keys.first}' has value '#{expected_hash.values.first}' but was '#{actual[expected_hash.keys.first]}'"
|
61
63
|
end
|
62
64
|
|
65
|
+
end
|
66
|
+
|
67
|
+
RSpec::Matchers.define :be_found do
|
68
|
+
|
69
|
+
match do |exchange|
|
70
|
+
expect(exchange.api_class.found?(exchange.response)).to be true
|
71
|
+
end
|
72
|
+
|
73
|
+
failure_message do |exchange|
|
74
|
+
"expected result #{exchange.response} to be found. Status code is #{exchange.response.code}"
|
75
|
+
end
|
76
|
+
|
63
77
|
end
|
data/lib/soaspec/rest_handler.rb
CHANGED
@@ -65,11 +65,13 @@ module Soaspec
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# Used in together with Exchange request that passes such override parameters
|
68
|
+
# @param [Hash] override_parameters Params to characterize REST request
|
68
69
|
def make_request(override_parameters)
|
69
70
|
test_values = override_parameters
|
70
71
|
test_values[:params] ||= {}
|
71
72
|
test_values[:suburl] = test_values[:suburl].to_s if test_values[:suburl]
|
72
73
|
|
74
|
+
begin
|
73
75
|
response = case test_values[:method]
|
74
76
|
when :post
|
75
77
|
if test_values[:suburl]
|
@@ -84,6 +86,9 @@ module Soaspec
|
|
84
86
|
@resource.send(test_values[:method].to_s, test_values[:params])
|
85
87
|
end
|
86
88
|
end
|
89
|
+
rescue RestClient::ExceptionWithResponse => e
|
90
|
+
response = e.response
|
91
|
+
end
|
87
92
|
Soaspec::SpecLogger.add_to(response)
|
88
93
|
response
|
89
94
|
end
|
@@ -92,6 +97,10 @@ module Soaspec
|
|
92
97
|
response.body.include? expected
|
93
98
|
end
|
94
99
|
|
100
|
+
def found?(response)
|
101
|
+
response.code != 404
|
102
|
+
end
|
103
|
+
|
95
104
|
# Convert XML or JSON response into a Hash
|
96
105
|
# @param [String] response Response as a String (either in XML or JSON)
|
97
106
|
# @return [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.28
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,7 +165,6 @@ files:
|
|
165
165
|
- lib/soaspec/xpath_not_found.rb
|
166
166
|
- soaspec.gemspec
|
167
167
|
- template/soap_template.xml
|
168
|
-
- test.rb
|
169
168
|
- test.wsdl
|
170
169
|
- test.xml
|
171
170
|
- test_rest.rb
|
data/test.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
module TestM
|
3
|
-
def do_something(text)
|
4
|
-
define_method('hi') do
|
5
|
-
puts 'hi' + text
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class BaseTest
|
11
|
-
extend TestM
|
12
|
-
end
|
13
|
-
|
14
|
-
class Tester < BaseTest
|
15
|
-
|
16
|
-
do_something('sam')
|
17
|
-
end
|
18
|
-
|
19
|
-
class Tes < BaseTest
|
20
|
-
do_something 'dsfd'
|
21
|
-
end
|
22
|
-
|
23
|
-
test = Tester.new
|
24
|
-
|
25
|
-
coll = Tes.new
|
26
|
-
|
27
|
-
test.hi
|
28
|
-
coll.hi
|