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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e1b4727e5991117fae5493694aa7a27d7de9811039d74eca4592a60b40d20c3
4
- data.tar.gz: dd3d6d1d836dd19cda286a8de96663711b5c1682b6a8411e6a051aa6a5d7c7e7
3
+ metadata.gz: f4a2e0e1d1ccfacade6173f0ebe8119a71438aeb5403af05bdf08373f98630d7
4
+ data.tar.gz: 063a4f40b5e8244adc654bb0e60b2dccb67b930b0ec4fa18045e3b005392004d
5
5
  SHA512:
6
- metadata.gz: 0d37e5d27ca8f93b1745b4ef0515d710bc6e00b85023c3cf6d3e9e3fc6d2e7d2e5b55eaf0a3c1d756f8dbc5048be6a5b50b7d03ed021263af8a943a15bc883ef
7
- data.tar.gz: af84325bb759302a20d0cb9cc96eb5015ee5e07815d8d00083bad3950024e1f70b09c03b17989e703bf448a7c6184814bd321fe2fb597c4ca6e0d209f27bd20d
6
+ metadata.gz: bdaaf1d7e90215b5f2f4d30ab0efd42ddf08f490dcaa77cba84a822b333020d63c34980420d9b9872c2db423635cf0d0fd0193a578826a31ad950795fa8a806e
7
+ data.tar.gz: 21a7cf4e9b0bbb8835284132edd029fd7221933d2cc0d044c8ca6f5fb81bfc406621cbefdd33422da1a3ce68a703a030965fd15b7da8e678693e25a78c1526e7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- webspicy (0.15.6)
4
+ webspicy (0.15.7)
5
5
  finitio (>= 0.8.0)
6
6
  http (>= 2)
7
7
  mustermann (~> 1.0)
@@ -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) }
@@ -10,6 +10,11 @@ TodoPatch = {
10
10
  description :? String
11
11
  }
12
12
 
13
+ TodoPut = {
14
+ id : Integer
15
+ description : String
16
+ }
17
+
13
18
  ErrorSchema = {
14
19
  error: String
15
20
  }
@@ -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
 
@@ -1,7 +1,7 @@
1
1
  @import finitio/data
2
2
 
3
3
  Method =
4
- String( s | s =~ /^(GET|POST|POST_FORM|PUT|DELETE|PATCH|OPTIONS)$/ )
4
+ String( s | s =~ /^(GET|POST|POST_FORM|PUT|DELETE|PATCH|PUT|OPTIONS)$/ )
5
5
 
6
6
  Tag = String( s | s.length > 0 )
7
7
 
@@ -2,7 +2,7 @@ module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 15
5
- TINY = 6
5
+ TINY = 7
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
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.6
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-06-05 00:00:00.000000000 Z
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.0.pre1
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!