webspicy 0.15.6 → 0.15.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/restful/Gemfile.lock +1 -1
- data/examples/restful/app.rb +15 -0
- data/examples/restful/webspicy/schema.fio +5 -0
- data/examples/restful/webspicy/todo/putTodo.yml +65 -0
- data/lib/webspicy/client/http_client.rb +12 -0
- data/lib/webspicy/client/rack_test_client.rb +13 -0
- data/lib/webspicy/formaldoc.fio +1 -1
- data/lib/webspicy/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4a2e0e1d1ccfacade6173f0ebe8119a71438aeb5403af05bdf08373f98630d7
|
4
|
+
data.tar.gz: 063a4f40b5e8244adc654bb0e60b2dccb67b930b0ec4fa18045e3b005392004d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdaaf1d7e90215b5f2f4d30ab0efd42ddf08f490dcaa77cba84a822b333020d63c34980420d9b9872c2db423635cf0d0fd0193a578826a31ad950795fa8a806e
|
7
|
+
data.tar.gz: 21a7cf4e9b0bbb8835284132edd029fd7221933d2cc0d044c8ca6f5fb81bfc406621cbefdd33422da1a3ce68a703a030965fd15b7da8e678693e25a78c1526e7
|
data/examples/restful/app.rb
CHANGED
@@ -119,6 +119,21 @@ patch '/todo/:id', :auth => :user do |id|
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
put '/todo/:id', :auth => :user do |id|
|
123
|
+
content_type :json
|
124
|
+
todo = settings.todolist.find{|todo| todo[:id] == Integer(id) }
|
125
|
+
if todo.nil?
|
126
|
+
status 404
|
127
|
+
{error: "No such todo"}.to_json
|
128
|
+
else
|
129
|
+
put = SCHEMA["TodoPut"].dress(loaded_body.merge(id: Integer(id)))
|
130
|
+
updated = todo.merge(put)
|
131
|
+
settings.todolist = settings.todolist.reject{|todo| todo[:id] == Integer(id) }
|
132
|
+
settings.todolist << updated
|
133
|
+
updated.to_json
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
122
137
|
delete '/todo/:id', :auth => :admin do |id|
|
123
138
|
content_type :json
|
124
139
|
todo = settings.todolist.find{|todo| todo[:id] == Integer(id) }
|
@@ -0,0 +1,65 @@
|
|
1
|
+
---
|
2
|
+
name: |-
|
3
|
+
Todo
|
4
|
+
|
5
|
+
url: |-
|
6
|
+
/todo/{id}
|
7
|
+
|
8
|
+
services:
|
9
|
+
- method: |-
|
10
|
+
PUT
|
11
|
+
|
12
|
+
description: |-
|
13
|
+
Update a single Todo item
|
14
|
+
|
15
|
+
preconditions:
|
16
|
+
- Must be authenticated
|
17
|
+
|
18
|
+
input_schema: |-
|
19
|
+
TodoPut
|
20
|
+
|
21
|
+
output_schema: |-
|
22
|
+
Todo
|
23
|
+
|
24
|
+
error_schema: |-
|
25
|
+
ErrorSchema
|
26
|
+
|
27
|
+
default_example:
|
28
|
+
expected:
|
29
|
+
content_type: application/json
|
30
|
+
status: 200
|
31
|
+
|
32
|
+
examples:
|
33
|
+
|
34
|
+
- description: |-
|
35
|
+
when requested on an existing TODO
|
36
|
+
params:
|
37
|
+
id: 1
|
38
|
+
description: 'hello world'
|
39
|
+
assert:
|
40
|
+
- "pathFD('', description: 'hello world')"
|
41
|
+
|
42
|
+
counterexamples:
|
43
|
+
|
44
|
+
- description: |-
|
45
|
+
when requested on an unexisting TODO
|
46
|
+
params:
|
47
|
+
id: 999254654
|
48
|
+
description: 'hello world'
|
49
|
+
expected:
|
50
|
+
content_type: application/json
|
51
|
+
status: 404
|
52
|
+
assert:
|
53
|
+
- "pathFD('', error: 'No such todo')"
|
54
|
+
|
55
|
+
- description: |-
|
56
|
+
when violating the Put data type
|
57
|
+
params:
|
58
|
+
id: 1
|
59
|
+
description: 'hello world'
|
60
|
+
nosuchone: 'foobar'
|
61
|
+
dress_params:
|
62
|
+
false
|
63
|
+
expected:
|
64
|
+
content_type: application/json
|
65
|
+
status: 400
|
@@ -107,6 +107,18 @@ module Webspicy
|
|
107
107
|
@last_response
|
108
108
|
end
|
109
109
|
|
110
|
+
def put(url, params = {}, headers = nil, body = nil)
|
111
|
+
info_request("PUT", url, params, headers, body)
|
112
|
+
|
113
|
+
headers ||= {}
|
114
|
+
headers['Content-Type'] ||= 'application/json'
|
115
|
+
@last_response = HTTP[headers].put(url, body: params.to_json)
|
116
|
+
|
117
|
+
debug_response(@last_response)
|
118
|
+
|
119
|
+
@last_response
|
120
|
+
end
|
121
|
+
|
110
122
|
def post_form(url, params = {}, headers = nil, body = nil)
|
111
123
|
info_request("POST", url, params, headers, body)
|
112
124
|
|
@@ -126,6 +126,19 @@ module Webspicy
|
|
126
126
|
@last_response
|
127
127
|
end
|
128
128
|
|
129
|
+
def put(url, params = {}, headers = nil, body = nil)
|
130
|
+
handler = get_handler(headers)
|
131
|
+
|
132
|
+
info_request("PUT", url, params, headers, body)
|
133
|
+
|
134
|
+
handler.put(url, params.to_json, {"CONTENT_TYPE" => "application/json"})
|
135
|
+
@last_response = handler.last_response
|
136
|
+
|
137
|
+
debug_response(@last_response)
|
138
|
+
|
139
|
+
@last_response
|
140
|
+
end
|
141
|
+
|
129
142
|
def post_form(url, params = {}, headers = nil, body = nil)
|
130
143
|
handler = get_handler(headers)
|
131
144
|
|
data/lib/webspicy/formaldoc.fio
CHANGED
data/lib/webspicy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webspicy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -206,6 +206,7 @@ files:
|
|
206
206
|
- examples/restful/webspicy/todo/postCsv.yml
|
207
207
|
- examples/restful/webspicy/todo/postFile.yml
|
208
208
|
- examples/restful/webspicy/todo/postTodos.yml
|
209
|
+
- examples/restful/webspicy/todo/putTodo.yml
|
209
210
|
- examples/restful/webspicy/todo/todos.csv
|
210
211
|
- lib/webspicy.rb
|
211
212
|
- lib/webspicy/checker.rb
|
@@ -265,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
266
|
- !ruby/object:Gem::Version
|
266
267
|
version: '0'
|
267
268
|
requirements: []
|
268
|
-
rubygems_version: 3.1.
|
269
|
+
rubygems_version: 3.1.2
|
269
270
|
signing_key:
|
270
271
|
specification_version: 4
|
271
272
|
summary: Webspicy helps testing web services as software operation black boxes!
|