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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 908d8b0ef22286c2ca694e2382e394c197e366a4
4
- data.tar.gz: dcc17777f4eca00da363246371ac3413fa04ea61
3
+ metadata.gz: 18f0661c8b343eccfa911819e895b4a971f18e91
4
+ data.tar.gz: 6b9f9aa4d5a318efa2c0c71962fbc93ec3198dcb
5
5
  SHA512:
6
- metadata.gz: 0c1e6d0b7310a9ed57d738aec9b032a0769922ecf417d50a95351c426f9b77555ebb2a7d6cefb05e4bf90f89f21efd20864e79c5b5fc1a0f80d3a82e0abddb3b
7
- data.tar.gz: 1b6548bcc759d783fa362290b3d9a8cf425d88ac0682c3b213e8b559ff3b08b1dfcd3e51d35e8a5bced08498b1b44ca2203c1a72148df3de1f05148cb557f85b
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soaspec (0.0.27)
4
+ soaspec (0.0.28)
5
5
  rest-client (>= 2.0)
6
6
  rspec (~> 3.0)
7
7
  rspec-its (>= 1.2.0)
@@ -3,7 +3,7 @@ japan:
3
3
  country_name: 'Japan'
4
4
 
5
5
  pet:
6
- id: '0'
6
+ id: '1'
7
7
  category:
8
8
  id: '1'
9
9
  name: 'string'
@@ -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(@response)
38
+ @api_class.status_code_for(self.response)
40
39
  end
41
40
 
42
41
  # Extract value from path api class
@@ -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
@@ -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]
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.27'
2
+ VERSION = '0.0.28'
3
3
  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.0.27
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-04 00:00:00.000000000 Z
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