cucumber-http 0.5.1 → 0.7.1
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/README.md +35 -4
- data/lib/cucumber/http/benchmark_steps.rb +1 -1
- data/lib/cucumber/http/configuration.rb +7 -0
- data/lib/cucumber/http/hooks.rb +1 -0
- data/lib/cucumber/http/http_steps.rb +31 -9
- data/lib/cucumber/http/version.rb +1 -1
- data/lib/cucumber/http/world_extensions/multipart_payload.rb +21 -0
- data/lib/cucumber/http/world_extensions/request.rb +8 -3
- data/lib/cucumber/http/world_extensions.rb +1 -0
- data/lib/cucumber/http.rb +9 -1
- metadata +8 -7
- data/lib/cucumber/http/transforms.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0232a60b32d3567ea573d9d14ed9f20855d73dab6606f0f34f4d99b73c466349
|
4
|
+
data.tar.gz: b7a4607176199b8ec28d08421006cee16c9a87f93550f6022ba0a4eb77130061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faec65815b43fc54d5e99dbfeeb901513d3d8626761f263de337d1f723bbac0283ae7e6fe1b3b93b6c436b4c5c3e7c883921952a5842cf347dcb68187aa9a0e7
|
7
|
+
data.tar.gz: 163dcbabd2c0b8d488ee9f945fa4d56505cc8b32692a3d3d23b906ae3a1bab8b53c12f4321e6d260c743ca2ad2bc51d47c73afccc0d324208cb2362c358672b5
|
data/README.md
CHANGED
@@ -50,6 +50,25 @@ Feature: Test the UDB3 labels API
|
|
50
50
|
And the JSON response at "privacy" should be "public"
|
51
51
|
```
|
52
52
|
|
53
|
+
```ruby
|
54
|
+
@api @images
|
55
|
+
Feature: Test the UDB3 image API
|
56
|
+
|
57
|
+
Background:
|
58
|
+
Given I am using the UDB3 development environment
|
59
|
+
And I am authorized as user "centraal_beheerder"
|
60
|
+
And I accept "application/json"
|
61
|
+
|
62
|
+
@imagecreate
|
63
|
+
Scenario: Create image
|
64
|
+
Given I set the form data properties to:
|
65
|
+
| description | logo |
|
66
|
+
| copyrightHolder | me |
|
67
|
+
| language | nl |
|
68
|
+
When I upload "file" from path "images/UDB.jpg" to "/images/"
|
69
|
+
Then the response status should be "201"
|
70
|
+
```
|
71
|
+
|
53
72
|
#### Benchmarking
|
54
73
|
|
55
74
|
```ruby
|
@@ -57,7 +76,7 @@ Given /^I am benchmarking$/
|
|
57
76
|
```
|
58
77
|
|
59
78
|
```ruby
|
60
|
-
Then
|
79
|
+
Then 'the elapsed time should be less than {float} second(s)'
|
61
80
|
```
|
62
81
|
|
63
82
|
#### HTTP
|
@@ -90,6 +109,10 @@ Given /^I send "(.*?)" and accept JSON$/
|
|
90
109
|
Given /^I send and accept JSON$/
|
91
110
|
```
|
92
111
|
|
112
|
+
```ruby
|
113
|
+
Given 'I set the form data properties to:'
|
114
|
+
```
|
115
|
+
|
93
116
|
```ruby
|
94
117
|
Given /^I set the JSON request payload to:$/
|
95
118
|
```
|
@@ -103,7 +126,15 @@ When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with paramet
|
|
103
126
|
```
|
104
127
|
|
105
128
|
```ruby
|
106
|
-
|
129
|
+
When 'I upload {string} from path {string} to {string}"'
|
130
|
+
```
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
Then 'the response status should be "{int}"'
|
134
|
+
```
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
Then 'the response status should not be "{int}"'
|
107
138
|
```
|
108
139
|
|
109
140
|
```ruby
|
@@ -138,7 +169,7 @@ Examples for testing the [REST API](https://apidoc.uitdatabank.be) of
|
|
138
169
|
|
139
170
|
Creating an organizer with a random name:
|
140
171
|
```ruby
|
141
|
-
When
|
172
|
+
When 'I create an organizer with a random name of {integer} character(s)' do |characters|
|
142
173
|
name = Faker::Lorem.characters(characters)
|
143
174
|
steps %Q{
|
144
175
|
Given I am using the UDB3 development environment
|
@@ -155,7 +186,7 @@ end
|
|
155
186
|
|
156
187
|
Creating a role with a random name:
|
157
188
|
```ruby
|
158
|
-
When
|
189
|
+
When 'I create a role with a random name of {integer} character(s)' do |characters|
|
159
190
|
name = Faker::Lorem.characters(characters)
|
160
191
|
steps %Q{
|
161
192
|
Given I am using the UDB3 development environment
|
@@ -2,7 +2,7 @@ Given /^I am benchmarking$/ do
|
|
2
2
|
@scenario_start_time = Time.now
|
3
3
|
end
|
4
4
|
|
5
|
-
Then
|
5
|
+
Then 'the elapsed time should be less than {float} second(s)' do |time|
|
6
6
|
elapsed = Time.now - @scenario_start_time
|
7
7
|
|
8
8
|
expect(elapsed).to be < time
|
data/lib/cucumber/http/hooks.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'json_spec'
|
2
|
-
|
3
1
|
Given /^I set headers?:$/ do |hdrs|
|
4
2
|
hdrs.rows_hash.each { |name, value| add_header(name, value) }
|
5
3
|
end
|
@@ -59,7 +57,7 @@ Given(/^I set the JSON request payload to:$/) do |payload|
|
|
59
57
|
end
|
60
58
|
|
61
59
|
Given(/^I set the JSON request payload from "(.*?)"$/) do |filename|
|
62
|
-
path = "#{
|
60
|
+
path = "#{Cucumber::Http.data_directory}/#{filename}"
|
63
61
|
|
64
62
|
if File.file? path
|
65
63
|
set_payload(JSON.parse(resolve(File.read(path))).to_json)
|
@@ -68,6 +66,13 @@ Given(/^I set the JSON request payload from "(.*?)"$/) do |filename|
|
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
69
|
+
Given 'I set the form data properties to:' do |table|
|
70
|
+
table.rows_hash.each { |name, value| add_multipart_payload(name, value) }
|
71
|
+
|
72
|
+
remove_header('Content-Type')
|
73
|
+
add_multipart_payload('multipart', true)
|
74
|
+
end
|
75
|
+
|
71
76
|
When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with parameters?:)?$/ do |*args|
|
72
77
|
method = args.shift
|
73
78
|
endpoint = resolve(args.shift)
|
@@ -88,16 +93,33 @@ When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with paramet
|
|
88
93
|
perform_request(method, request_url)
|
89
94
|
end
|
90
95
|
|
96
|
+
When 'I upload {string} from path {string} to {string}' do |key, filename, endpoint|
|
97
|
+
method = 'post'
|
98
|
+
payload_key = key
|
99
|
+
path = "#{Cucumber::Http.data_directory}/#{filename}"
|
100
|
+
|
101
|
+
request_url = URI.join(url, URI::encode(endpoint)).to_s
|
102
|
+
|
103
|
+
if File.file? path
|
104
|
+
remove_header('Content-Type')
|
105
|
+
add_multipart_payload(payload_key, File.new(path, 'rb'))
|
106
|
+
else
|
107
|
+
raise "File not found: '#{path}'"
|
108
|
+
end
|
109
|
+
|
110
|
+
perform_request(method, request_url)
|
111
|
+
end
|
112
|
+
|
91
113
|
When /^(?:I )?keep the value of the (?:JSON|json)(?: response)?(?: at "(.*)")? as "(.*)"$/ do |path, key|
|
92
114
|
JsonSpec.memorize(key, parse_json(last_json, path))
|
93
115
|
end
|
94
116
|
|
95
|
-
Then
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
117
|
+
Then 'the response status should be "{int}"' do |status_code|
|
118
|
+
expect(response[:status]).to eq(status_code)
|
119
|
+
end
|
120
|
+
|
121
|
+
Then 'the response status should not be "{int}"' do |status_code|
|
122
|
+
expect(response[:status]).not_to eq(status_code)
|
101
123
|
end
|
102
124
|
|
103
125
|
Then /^the response body should be valid JSON$/ do
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Http
|
3
|
+
module Payload
|
4
|
+
def multipart_payload
|
5
|
+
@multipart_payload ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_multipart_payload(key, value)
|
9
|
+
multipart_payload[key] = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def remove_multipart_payload(key)
|
13
|
+
multipart_payload.tap { |p| p.delete(key)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear_multipart_payload
|
17
|
+
multipart_payload.clear
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -14,12 +14,14 @@ module Cucumber
|
|
14
14
|
def perform_request(method, path)
|
15
15
|
add_header('params', parameters)
|
16
16
|
|
17
|
+
request_payload = multipart_payload.empty? ? payload : multipart_payload
|
18
|
+
|
17
19
|
begin
|
18
20
|
r = RestClient::Request.execute(
|
19
21
|
method: method.downcase,
|
20
22
|
url: path,
|
21
23
|
headers: headers,
|
22
|
-
payload:
|
24
|
+
payload: request_payload
|
23
25
|
)
|
24
26
|
rescue RestClient::Exception => e
|
25
27
|
r = e.response
|
@@ -27,13 +29,16 @@ module Cucumber
|
|
27
29
|
|
28
30
|
set_request('url', path)
|
29
31
|
set_request('method', method.upcase)
|
30
|
-
set_request('headers', headers)
|
32
|
+
set_request('headers', headers.tap { |hdrs| hdrs.delete('params')})
|
31
33
|
set_request('parameters', parameters)
|
32
|
-
set_request('payload',
|
34
|
+
set_request('payload', request_payload)
|
33
35
|
|
34
36
|
set_response('status', r.code)
|
35
37
|
set_response('body', r.body)
|
36
38
|
set_response('headers', r.raw_headers)
|
39
|
+
|
40
|
+
clear_multipart_payload
|
41
|
+
clear_payload
|
37
42
|
end
|
38
43
|
|
39
44
|
def clear_request
|
@@ -2,6 +2,7 @@ require_relative 'world_extensions/json_spec_interface'
|
|
2
2
|
require_relative 'world_extensions/headers'
|
3
3
|
require_relative 'world_extensions/parameters'
|
4
4
|
require_relative 'world_extensions/payload'
|
5
|
+
require_relative 'world_extensions/multipart_payload'
|
5
6
|
require_relative 'world_extensions/request'
|
6
7
|
require_relative 'world_extensions/response'
|
7
8
|
require_relative 'world_extensions/url'
|
data/lib/cucumber/http.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
require 'cucumber/http/transforms'
|
2
1
|
require 'cucumber/http/world_extensions'
|
3
2
|
require 'cucumber/http/hooks'
|
4
3
|
require 'cucumber/http/http_steps'
|
5
4
|
require 'cucumber/http/benchmark_steps'
|
6
5
|
require 'cucumber/http/debug_steps'
|
6
|
+
require 'cucumber/http/configuration'
|
7
|
+
require 'json_spec'
|
8
|
+
require 'json_spec/cucumber'
|
9
|
+
|
10
|
+
module Cucumber
|
11
|
+
module Http
|
12
|
+
extend Configuration
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristof Willaert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json_spec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,14 +104,15 @@ files:
|
|
104
104
|
- README.md
|
105
105
|
- lib/cucumber/http.rb
|
106
106
|
- lib/cucumber/http/benchmark_steps.rb
|
107
|
+
- lib/cucumber/http/configuration.rb
|
107
108
|
- lib/cucumber/http/debug_steps.rb
|
108
109
|
- lib/cucumber/http/hooks.rb
|
109
110
|
- lib/cucumber/http/http_steps.rb
|
110
|
-
- lib/cucumber/http/transforms.rb
|
111
111
|
- lib/cucumber/http/version.rb
|
112
112
|
- lib/cucumber/http/world_extensions.rb
|
113
113
|
- lib/cucumber/http/world_extensions/headers.rb
|
114
114
|
- lib/cucumber/http/world_extensions/json_spec_interface.rb
|
115
|
+
- lib/cucumber/http/world_extensions/multipart_payload.rb
|
115
116
|
- lib/cucumber/http/world_extensions/parameters.rb
|
116
117
|
- lib/cucumber/http/world_extensions/payload.rb
|
117
118
|
- lib/cucumber/http/world_extensions/request.rb
|