soaspec 0.0.28 → 0.0.29
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/exe/soaspec-generate +2 -1
- data/exe/soaspec-init +5 -52
- data/lib/soaspec.rb +1 -1
- data/lib/soaspec/basic_soap_handler.rb +23 -2
- data/lib/soaspec/{tester.rb → exchange_handler.rb} +2 -1
- data/lib/soaspec/exe_helpers.rb +40 -0
- data/lib/soaspec/rest_handler.rb +8 -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: 175c61fcf50ffcad25f8cfaf8ffcc508de469607
|
4
|
+
data.tar.gz: 6753d697bea4c8058cf005964a100b6edb7f809a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe07fbc0e1a63944070b2d4842527b1071005c8f61913a79de5990f943c2e4009de1c2f5ef28eadb9527ea8467f928be9f2189ee8cb18cf12d2b71c81f5b6875
|
7
|
+
data.tar.gz: db8b5cdac6ca0c6fafdaf1be2380984a354f3f25c0654225a3306606a136b1d38a600b41c9072ee363026aa9090ed0bd489c8d3964157693f20a11e7934bf6ce
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.29 / 2018-3-6
|
2
|
+
* Refactorings
|
3
|
+
* Base 'test' class from 'Tester' to 'ExhangeHandler'
|
4
|
+
* Made default Soap Handler class 'SoapHandler' and making use of 'BasicSoapHandler' deprecated
|
5
|
+
|
1
6
|
Version 0.0.28 / 2018-3-6
|
2
7
|
* Enhancements
|
3
8
|
* Added not_found matcher and used in spec example
|
data/Gemfile.lock
CHANGED
data/exe/soaspec-generate
CHANGED
@@ -100,7 +100,7 @@ end
|
|
100
100
|
|
101
101
|
require 'soaspec'
|
102
102
|
|
103
|
-
class <%= @name %> < Soaspec::
|
103
|
+
class <%= @name %> < Soaspec::SoapHandler
|
104
104
|
# Add to or override default Savon client options
|
105
105
|
def savon_options
|
106
106
|
{
|
@@ -145,6 +145,7 @@ create_file filename: 'Rakefile', content: rake_content, ignore_if_present: true
|
|
145
145
|
create_file filename: 'Gemfile', content: gem_content, ignore_if_present: true
|
146
146
|
create_folder 'spec'
|
147
147
|
create_file filename: 'spec/spec_helper.rb', content: spec_helper_content
|
148
|
+
create_file filename: 'README.md', content: readme_content, ignore_if_present: true
|
148
149
|
|
149
150
|
create_folder 'logs'
|
150
151
|
create_folder 'config'
|
data/exe/soaspec-init
CHANGED
@@ -9,18 +9,6 @@ include Soaspec::ExeHelpers
|
|
9
9
|
|
10
10
|
puts 'Creating files for soaspec'
|
11
11
|
|
12
|
-
gem_content = <<-EOF
|
13
|
-
|
14
|
-
source 'https://rubygems.org'
|
15
|
-
|
16
|
-
gem 'data_magic'
|
17
|
-
gem 'require_all'
|
18
|
-
gem 'rspec_junit_formatter'
|
19
|
-
gem 'rake'
|
20
|
-
gem 'soaspec'
|
21
|
-
|
22
|
-
EOF
|
23
|
-
|
24
12
|
weather_web_service = <<-EOF
|
25
13
|
|
26
14
|
require 'soaspec'
|
@@ -28,7 +16,7 @@ require 'soaspec'
|
|
28
16
|
# This class is not part of the gem. It's an example of a class you can make
|
29
17
|
# to describe your APIs. Usually this would exist in the 'lib' directory
|
30
18
|
# Common configuration for the Savon client should go here
|
31
|
-
class WeatherWebService < Soaspec::
|
19
|
+
class WeatherWebService < Soaspec::SoapHandler
|
32
20
|
# Add to or override default Savon client options
|
33
21
|
def savon_options
|
34
22
|
{
|
@@ -84,9 +72,11 @@ soap_example.default_hash = { city_name: 'Sydney', country_name: 'Australia' }
|
|
84
72
|
|
85
73
|
end
|
86
74
|
|
87
|
-
|
75
|
+
error_example = WeatherWebService.new('Get Weather')
|
76
|
+
error_example.operation = :get_weather
|
77
|
+
error_example.default_hash = { city_name: 'Washington' }
|
88
78
|
context 'error scenarios' do
|
89
|
-
context
|
79
|
+
context error_example do
|
90
80
|
describe Exchange.new(:error) do
|
91
81
|
it_behaves_like 'error scenario'
|
92
82
|
end
|
@@ -128,43 +118,6 @@ japan:
|
|
128
118
|
|
129
119
|
EOF
|
130
120
|
|
131
|
-
readme_content = <<-EOF
|
132
|
-
|
133
|
-
# Prerequisites
|
134
|
-
This creates files within an existing folder. It could add onto an existing project.
|
135
|
-
For a new project create a folder and be at it's location on the command line
|
136
|
-
|
137
|
-
```
|
138
|
-
mkdir soaspec_test
|
139
|
-
cd soaspec_test
|
140
|
-
```
|
141
|
-
|
142
|
-
Run `bundle install` to install the gems mentioned in the Gemfile.
|
143
|
-
|
144
|
-
To avoid conflict with gems on the machine globally it may be better to specify gem location with:
|
145
|
-
|
146
|
-
`bundle install --path ~/.gem`
|
147
|
-
|
148
|
-
# Running tests
|
149
|
-
On the command line type:
|
150
|
-
`bundle exec rake spec` or simply `bundle exec rake`
|
151
|
-
|
152
|
-
# Structure
|
153
|
-
|
154
|
-
## Tests
|
155
|
-
Tests are within the 'spec' folder and end in '_spec'. Setup and teardown for tests is in 'spec/spec_helper'
|
156
|
-
|
157
|
-
## Templates
|
158
|
-
These are the base requests with ERB inside them to create smartly changing requests accoring to the test.yml
|
159
|
-
|
160
|
-
## Libaries
|
161
|
-
Libaries to be installed are in 'Gemfile'. Specific gem versions can be specified here and enforeced with `bundle exec rake`
|
162
|
-
|
163
|
-
## Reports
|
164
|
-
Reports are shown in the 'logs' folder. By default Rake produces a junit, an html report, and a traffic.log file with the API request and responses in it
|
165
|
-
|
166
|
-
EOF
|
167
|
-
|
168
121
|
create_file(filename: 'Gemfile', content: gem_content)
|
169
122
|
create_file(filename: 'Rakefile', content: rake_content)
|
170
123
|
create_file(filename: 'README.md', content: readme_content)
|
data/lib/soaspec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require_relative '
|
2
|
+
require_relative 'exchange_handler'
|
3
3
|
require_relative 'hash_methods'
|
4
4
|
require_relative 'xpath_not_found'
|
5
5
|
require_relative 'accessors'
|
@@ -17,7 +17,7 @@ module Soaspec
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# Wraps around Savon client defining default values dependent on the soap request
|
20
|
-
class
|
20
|
+
class SoapHandler < ExchangeHandler
|
21
21
|
extend Soaspec::Accessors
|
22
22
|
extend Soaspec::SoapAccessors
|
23
23
|
|
@@ -106,6 +106,19 @@ module Soaspec
|
|
106
106
|
@default_hash = Soaspec::Environment.always_use_keys? ? hash.transform_keys_to_symbols : hash
|
107
107
|
end
|
108
108
|
|
109
|
+
# @param [Hash] format Format of expected result
|
110
|
+
# @return [Object] Generic body to be displayed in error messages
|
111
|
+
def response_body(response, format: :hash)
|
112
|
+
case format
|
113
|
+
when :hash
|
114
|
+
response.body
|
115
|
+
when :xml
|
116
|
+
response.body.to_xml
|
117
|
+
else
|
118
|
+
response.body
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
109
122
|
def status_code_for(response)
|
110
123
|
response.http.code
|
111
124
|
end
|
@@ -139,4 +152,12 @@ module Soaspec
|
|
139
152
|
end
|
140
153
|
|
141
154
|
end
|
155
|
+
|
156
|
+
class BasicSoapHandler < SoapHandler
|
157
|
+
|
158
|
+
def initialize(name, specific_options = {})
|
159
|
+
super
|
160
|
+
warn "'BasicSoapHandler' class is Deprecated. Please use 'SoapHandler' instead"
|
161
|
+
end
|
162
|
+
end
|
142
163
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
|
2
2
|
module Soaspec
|
3
|
+
# Inherit this for a class describing how to implement a particular exchange.
|
3
4
|
# Has basic methods common for methods defining RSpec tests in YAML
|
4
|
-
class
|
5
|
+
class ExchangeHandler
|
5
6
|
|
6
7
|
# Retrieve the name of the template file to be used in the API request
|
7
8
|
attr_reader :template_name
|
data/lib/soaspec/exe_helpers.rb
CHANGED
@@ -83,6 +83,46 @@ end
|
|
83
83
|
EOF
|
84
84
|
end
|
85
85
|
|
86
|
+
# @return [String] Content of README.md to aid someone getting started with this using this gem
|
87
|
+
def readme_content
|
88
|
+
<<-EOF
|
89
|
+
|
90
|
+
# Prerequisites
|
91
|
+
This creates files within an existing folder. It could add onto an existing project.
|
92
|
+
For a new project create a folder and be at it's location on the command line
|
93
|
+
|
94
|
+
```
|
95
|
+
mkdir soaspec_test
|
96
|
+
cd soaspec_test
|
97
|
+
```
|
98
|
+
|
99
|
+
Run `bundle install` to install the gems mentioned in the Gemfile.
|
100
|
+
|
101
|
+
To avoid conflict with gems on the machine globally it may be better to specify gem location with:
|
102
|
+
|
103
|
+
`bundle install --path ~/.gem`
|
104
|
+
|
105
|
+
# Running tests
|
106
|
+
On the command line type:
|
107
|
+
`bundle exec rake spec` or simply `bundle exec rake`
|
108
|
+
|
109
|
+
# Structure
|
110
|
+
|
111
|
+
## Tests
|
112
|
+
Tests are within the 'spec' folder and end in '_spec'. Setup and teardown for tests is in 'spec/spec_helper'
|
113
|
+
|
114
|
+
## Templates
|
115
|
+
These are the base requests with ERB inside them to create smartly changing requests accoring to the test.yml
|
116
|
+
|
117
|
+
## Libaries
|
118
|
+
Libaries to be installed are in 'Gemfile'. Specific gem versions can be specified here and enforeced with `bundle exec rake`
|
119
|
+
|
120
|
+
## Reports
|
121
|
+
Reports are shown in the 'logs' folder. By default Rake produces a junit, an html report, and a traffic.log file with the API request and responses in it
|
122
|
+
|
123
|
+
EOF
|
124
|
+
end
|
125
|
+
|
86
126
|
# Convert key in camelcase to underscore separated (snakecase)
|
87
127
|
def underscore_key(key)
|
88
128
|
key.to_s.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
data/lib/soaspec/rest_handler.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require_relative '
|
2
|
+
require_relative 'exchange_handler'
|
3
3
|
require_relative 'hash_methods'
|
4
4
|
require_relative 'xpath_not_found'
|
5
5
|
require_relative 'accessors'
|
@@ -21,7 +21,7 @@ module Soaspec
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# Wraps around Savon client defining default values dependent on the soap request
|
24
|
-
class RestHandler <
|
24
|
+
class RestHandler < ExchangeHandler
|
25
25
|
extend Soaspec::RestAccessors
|
26
26
|
extend Soaspec::Accessors
|
27
27
|
|
@@ -93,6 +93,12 @@ module Soaspec
|
|
93
93
|
response
|
94
94
|
end
|
95
95
|
|
96
|
+
# @param [Hash] format Format of expected result. Ignored for this
|
97
|
+
# @return [Object] Generic body to be displayed in error messages
|
98
|
+
def response_body(response, format: :hash)
|
99
|
+
extract_hash response
|
100
|
+
end
|
101
|
+
|
96
102
|
def include_in_body?(response, expected)
|
97
103
|
response.body.include? expected
|
98
104
|
end
|
data/lib/soaspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
@@ -154,13 +154,13 @@ files:
|
|
154
154
|
- lib/soaspec/accessors.rb
|
155
155
|
- lib/soaspec/basic_soap_handler.rb
|
156
156
|
- lib/soaspec/exchange.rb
|
157
|
+
- lib/soaspec/exchange_handler.rb
|
157
158
|
- lib/soaspec/exe_helpers.rb
|
158
159
|
- lib/soaspec/hash_methods.rb
|
159
160
|
- lib/soaspec/matchers.rb
|
160
161
|
- lib/soaspec/rest_handler.rb
|
161
162
|
- lib/soaspec/soaspec_shared_examples.rb
|
162
163
|
- lib/soaspec/spec_logger.rb
|
163
|
-
- lib/soaspec/tester.rb
|
164
164
|
- lib/soaspec/version.rb
|
165
165
|
- lib/soaspec/xpath_not_found.rb
|
166
166
|
- soaspec.gemspec
|