cucumber-http 0.6.0 → 0.7.0
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 +27 -0
- data/lib/cucumber/http/hooks.rb +1 -0
- data/lib/cucumber/http/http_steps.rb +24 -0
- 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
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 505a70f70933a819f67d4fa163985fe75115233481959ff1742cffc61cac4adb
|
4
|
+
data.tar.gz: 2ae449691aa78c1008fedf802b5309cf0f74b29b75d08fa1e274335b0e0630e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46653d3f35be042a2f0c10333e241cffc4c4ae64e10731b6e6b10769d9809e764eb8ebf4932b1ab402eb598781cde0531f55d0e16acde1d6bd34b5a5b2199d88
|
7
|
+
data.tar.gz: 17d7bbabe915ec23ca015a39806f275e4ae44f0d90d6b65b4f71a92666f6fb406f310bbdd6df69a2b9147bb738f4b76bbb102b2c0e4ee3f6ca01c5fb7a3cf77c
|
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
|
@@ -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
|
```
|
@@ -102,6 +125,10 @@ Given /^I set the JSON request payload from "(.*?)"$/
|
|
102
125
|
When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with parameters?:)?$/
|
103
126
|
```
|
104
127
|
|
128
|
+
```ruby
|
129
|
+
When 'I upload {string} from path {string} to {string}"'
|
130
|
+
```
|
131
|
+
|
105
132
|
```ruby
|
106
133
|
Then 'the response status should be "{int}"'
|
107
134
|
```
|
data/lib/cucumber/http/hooks.rb
CHANGED
@@ -68,6 +68,13 @@ Given(/^I set the JSON request payload from "(.*?)"$/) do |filename|
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
Given 'I set the form data properties to:' do |table|
|
72
|
+
table.rows_hash.each { |name, value| add_multipart_payload(name, value) }
|
73
|
+
|
74
|
+
remove_header('Content-Type')
|
75
|
+
add_multipart_payload('multipart', true)
|
76
|
+
end
|
77
|
+
|
71
78
|
When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with parameters?:)?$/ do |*args|
|
72
79
|
method = args.shift
|
73
80
|
endpoint = resolve(args.shift)
|
@@ -88,6 +95,23 @@ When /^I send a (GET|POST|PATCH|PUT|DELETE) request to "([^"]*)"(?: with paramet
|
|
88
95
|
perform_request(method, request_url)
|
89
96
|
end
|
90
97
|
|
98
|
+
When 'I upload {string} from path {string} to {string}' do |key, filename, endpoint|
|
99
|
+
method = 'post'
|
100
|
+
payload_key = key
|
101
|
+
path = "#{Dir.pwd}/features/support/data/#{filename}"
|
102
|
+
|
103
|
+
request_url = URI.join(url, URI::encode(endpoint)).to_s
|
104
|
+
|
105
|
+
if File.file? path
|
106
|
+
remove_header('Content-Type')
|
107
|
+
add_multipart_payload(payload_key, File.new(path, 'rb'))
|
108
|
+
else
|
109
|
+
raise "File not found: '#{path}'"
|
110
|
+
end
|
111
|
+
|
112
|
+
perform_request(method, request_url)
|
113
|
+
end
|
114
|
+
|
91
115
|
When /^(?:I )?keep the value of the (?:JSON|json)(?: response)?(?: at "(.*)")? as "(.*)"$/ do |path, key|
|
92
116
|
JsonSpec.memorize(key, parse_json(last_json, path))
|
93
117
|
end
|
@@ -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'
|
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.0
|
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-02-
|
11
|
+
date: 2022-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/cucumber/http/world_extensions.rb
|
112
112
|
- lib/cucumber/http/world_extensions/headers.rb
|
113
113
|
- lib/cucumber/http/world_extensions/json_spec_interface.rb
|
114
|
+
- lib/cucumber/http/world_extensions/multipart_payload.rb
|
114
115
|
- lib/cucumber/http/world_extensions/parameters.rb
|
115
116
|
- lib/cucumber/http/world_extensions/payload.rb
|
116
117
|
- lib/cucumber/http/world_extensions/request.rb
|