soaspec 0.2.7 → 0.2.8
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/.gitlab-ci.yml +4 -3
- data/ChangeLog +4 -0
- data/README.md +22 -19
- data/lib/soaspec/version.rb +1 -1
- data/soaspec.gemspec +4 -5
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a446e205c6a72dceb41dada3f7b910587629e0c0
|
4
|
+
data.tar.gz: f827d2d372ff408503f1111175b78cfa028a845f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cc6e07e30560774e7b5e9c9568bc15941df4cdfbb19102c97e322e53ffb3826d9d34d8e91cbb9182deb6745c710d23fef24dfb9d1c81688ae13131066f7f2e3
|
7
|
+
data.tar.gz: dee062b10eafcef1e52c96137108b4bdc0013d633e2871d9a85227e116580939144466b87ddd9f025f27c4b44e22e0d49b70c52ba94e8652e7172f3d881c9ccb
|
data/.gitlab-ci.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
image: ruby:2.5
|
2
|
+
|
1
3
|
before_script:
|
2
|
-
# - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
|
3
4
|
- ruby -v
|
4
5
|
- which ruby
|
5
|
-
- gem install bundler rake
|
6
|
+
- gem install bundler rake
|
6
7
|
- bundle install --jobs $(nproc) "${FLAGS[@]}"
|
7
8
|
|
8
9
|
rspec:
|
@@ -19,7 +20,7 @@ cucumber:
|
|
19
20
|
- bundle exec cucumber
|
20
21
|
|
21
22
|
code_quality:
|
22
|
-
image:
|
23
|
+
image: ruby:2.5
|
23
24
|
variables:
|
24
25
|
DOCKER_DRIVER: overlay2
|
25
26
|
allow_failure: true
|
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
This gem helps to represent multiple API tests against a backend briefly, concisely and clearly.
|
4
4
|
It is essentially a wrapper around the Savon and RestClient gems, adding useful functionality including
|
5
5
|
|
6
|
-
* Creating multiple API calls from the same base configuration through the use of an `ExchangeHandler`
|
6
|
+
* Creating multiple API calls from the same base configuration through the use of an `ExchangeHandler` class
|
7
7
|
* Extracting values from response body's through either `XPath` or `JSONPath`
|
8
|
-
* Building up a custom RSpec `success scenario` shared example to
|
9
|
-
* Methods
|
8
|
+
* Building up a custom RSpec `success scenario` shared example to reuse common tests on an API
|
9
|
+
* Methods simplifying setting and extracting values from a `Request/Response` pair (`Exchange`)
|
10
10
|
* Waiting for a particular response from an API by polling it
|
11
|
-
*
|
12
|
-
* Generating initial code for an API with `soaspec new`
|
13
|
-
*
|
11
|
+
* Representing paths to values from a response with business-meaningful method names
|
12
|
+
* Generating initial code for testing an API with `soaspec new`
|
13
|
+
* Accessing and utilising `oauth2` access tokens
|
14
14
|
* Hosting a `virtual_server` that simulates REST & SOAP responses from an API
|
15
15
|
|
16
16
|
[](https://gitlab.com/samuel-garratt/soaspec/pipelines)
|
@@ -60,12 +60,12 @@ You can also use `soaspec generate` to generate a set of tests from a WSDL. This
|
|
60
60
|
for such defaults. When describing an API override this in 'savon_options' method
|
61
61
|
* REST - this uses the resource class from the Rest-Client gem behind the scenes.
|
62
62
|
|
63
|
-
See [
|
63
|
+
See [spec](spec) and [features](features) for example of usage.
|
64
64
|
|
65
65
|
### ExchangeHandler
|
66
66
|
|
67
|
-
To start with a class inheriting from a ‘Handler’ class for each web service that
|
68
|
-
In this class you define the common parameters used for testing
|
67
|
+
To start with, create a class inheriting from a ‘Handler’ class for each web service that needs testing.
|
68
|
+
In this class you define the common parameters used for testing it.
|
69
69
|
|
70
70
|
For example:
|
71
71
|
|
@@ -82,13 +82,16 @@ class PuppyService < Soaspec::RestHandler
|
|
82
82
|
end
|
83
83
|
```
|
84
84
|
|
85
|
+
> You can easily create a exchange handler with the `soaspec add` command. This will also add comments explaining common methods that can be used
|
86
|
+
|
85
87
|
### Exchange
|
86
88
|
|
87
|
-
|
88
|
-
Upon initialization of the Exchange object or later on through setters, parameters specific to this request are set
|
89
|
-
|
90
|
-
Once this request has been made, all following accessors of the response will just use the previous request made.
|
89
|
+
After creating the `ExchangeHandler`, you reference this class in creating `Exchange`s (objects that each represent a request / response pair).
|
90
|
+
Upon initialization of the Exchange object (or later on through setters), parameters specific to this request are set.
|
91
|
+
Most getters of the `Exchange` are on the response & will implicitly trigger the API request to be made.
|
92
|
+
Once this request has been made, all following accessors of the response will just use the response of the previous request made.
|
91
93
|
|
94
|
+
For example, to create a http post using the above `ExchangeHandler` and extract a value from the response body using JSON PATH.
|
92
95
|
```ruby
|
93
96
|
exchange = PuppyService.post(body: { status: 'sold' }) # The 'body' key will convert it's value from a Hash to JSON
|
94
97
|
# Create a new Exchange that will post to 'http://petstore.swagger.io/v2/pet' with JSON { "status": "sold" }
|
@@ -96,8 +99,8 @@ exchange.category_id
|
|
96
99
|
# This will trigger the request to be made & return a value at JSON path $..category.id, throwing an exception if not found
|
97
100
|
```
|
98
101
|
|
99
|
-
See [Request Body Parameters](wikis/RequestBodyParameters) for more details on setting a request body.
|
100
|
-
See [Creating an Exchange](wikis/CreatingExchange) for details on how to create an Exchange.
|
102
|
+
See [Request Body Parameters](https://gitlab.com/samuel-garratt/soaspec/wikis/RequestBodyParameters) for more details on setting a request body.
|
103
|
+
See [Creating an Exchange](https://gitlab.com/samuel-garratt/soaspec/wikis/CreatingExchange) for details on how to create an Exchange.
|
101
104
|
|
102
105
|
### RSpec
|
103
106
|
|
@@ -128,15 +131,15 @@ end
|
|
128
131
|
If you're using `Cucumber` then I would recommend the following
|
129
132
|
|
130
133
|
In the `Given` (or background) specify the `Exchange` object.
|
131
|
-
Either store this as an instance variable (e.g `@exchange`) or use the global `Soaspec.last_exchange`
|
134
|
+
Either store this as an instance variable (e.g `@exchange`) or use the global `Soaspec.last_exchange` (which is automatically set).
|
132
135
|
|
133
|
-
In the `When
|
136
|
+
In the `When`, use the `call` method to make the request `@exchange.call`. If problems occur in making the request this should separate such failures from issues with the response.
|
134
137
|
|
135
|
-
In the `Then
|
138
|
+
In the `Then`, make the assertions from the `@exchange` object.
|
136
139
|
E.g
|
137
140
|
```ruby
|
138
141
|
expect(@exchange['message']).to include 'success'
|
139
|
-
expect(@exchange.status_code).to eq
|
142
|
+
expect(@exchange.status_code).to eq 200
|
140
143
|
```
|
141
144
|
|
142
145
|
## Development
|
data/lib/soaspec/version.rb
CHANGED
data/soaspec.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'soaspec/version'
|
@@ -9,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
9
8
|
spec.authors = ['SamuelGarrattIQA']
|
10
9
|
spec.email = ['samuel.garratt@integrationqa.com']
|
11
10
|
|
12
|
-
spec.summary = "Helps to create
|
13
|
-
spec.description = "Helps to create
|
14
|
-
the same configuration "
|
11
|
+
spec.summary = "Helps to create tests for 'SOAP' or 'REST' apis "
|
12
|
+
spec.description = "Helps to create tests for 'SOAP' or 'REST' apis. Easily represent multiple requests with
|
13
|
+
the same configuration. Examples designed for RSpec and Cucumber."
|
15
14
|
spec.homepage = 'https://gitlab.com/samuel-garratt/soaspec'
|
16
15
|
spec.license = 'MIT'
|
17
16
|
|
@@ -38,7 +37,7 @@ the same configuration "
|
|
38
37
|
spec.add_dependency 'nokogiri'
|
39
38
|
spec.add_dependency 'rest-client', '>= 2.0' # REST
|
40
39
|
spec.add_dependency 'rspec', '~> 3.0' # This framework is designed to work with RSpec
|
41
|
-
spec.add_dependency 'rspec-its'
|
40
|
+
spec.add_dependency 'rspec-its'
|
42
41
|
spec.add_dependency 'savon', '>= 2' # SOAP
|
43
42
|
spec.add_dependency 'sinatra'
|
44
43
|
spec.add_dependency 'sinatra-basic-auth'
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SamuelGarrattIQA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -240,14 +240,14 @@ dependencies:
|
|
240
240
|
requirements:
|
241
241
|
- - ">="
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
243
|
+
version: '0'
|
244
244
|
type: :runtime
|
245
245
|
prerelease: false
|
246
246
|
version_requirements: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
248
|
- - ">="
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version:
|
250
|
+
version: '0'
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: savon
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,8 +332,9 @@ dependencies:
|
|
332
332
|
- - ">="
|
333
333
|
- !ruby/object:Gem::Version
|
334
334
|
version: 1.1.5
|
335
|
-
description:
|
336
|
-
multiple requests with
|
335
|
+
description: |-
|
336
|
+
Helps to create tests for 'SOAP' or 'REST' apis. Easily represent multiple requests with
|
337
|
+
the same configuration. Examples designed for RSpec and Cucumber.
|
337
338
|
email:
|
338
339
|
- samuel.garratt@integrationqa.com
|
339
340
|
executables:
|
@@ -436,5 +437,5 @@ rubyforge_project:
|
|
436
437
|
rubygems_version: 2.6.14
|
437
438
|
signing_key:
|
438
439
|
specification_version: 4
|
439
|
-
summary: Helps to create
|
440
|
+
summary: Helps to create tests for 'SOAP' or 'REST' apis
|
440
441
|
test_files: []
|