webspicy 0.1.0 → 0.2.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/examples/restful/Gemfile.lock +1 -1
- data/examples/restful/Rakefile +15 -11
- data/examples/restful/app.rb +13 -0
- data/examples/restful/webspicy/todo/deleteTodo.yml +50 -0
- data/lib/webspicy/client/http_client.rb +9 -0
- data/lib/webspicy/client/rack_test_client.rb +11 -0
- data/lib/webspicy/formaldoc.fio +1 -1
- data/lib/webspicy/resource/service/invocation.rb +6 -2
- data/lib/webspicy/resource/service/test_case.rb +1 -1
- data/lib/webspicy/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4aae5afefcdda4fe5593cfc4626bfdb52143c07
|
4
|
+
data.tar.gz: 6c0653d7ac94dacb5ea97325cdc696f458b7f73d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d013ffd5cc0eb2c1edeb8609709ffe467696d817d6beff6abc2c615697ef3d9686e30422399afb0fbb71180a76e9c6aa94a2f68961cc167e2e23403dfeb15a7f
|
7
|
+
data.tar.gz: 19bae47fc5674ab351403e0c338ae4a4b584f68b355aea80f57ed816fadba0e26ad0f53a9dc4f9e998eec05db8b74a9bd2cb1cb30ee98eb3b15261ca8aa8f887
|
data/examples/restful/Rakefile
CHANGED
@@ -2,16 +2,17 @@ $LOAD_PATH.unshift File.expand_path("..", __FILE__)
|
|
2
2
|
require 'app'
|
3
3
|
require 'webspicy'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
c.add_folder Path.dir/"webspicy"
|
10
|
-
end
|
11
|
-
Webspicy::Checker.new(config).call
|
5
|
+
desc "Checks all .yml definition files"
|
6
|
+
task :check do
|
7
|
+
config = Webspicy::Configuration.new do |c|
|
8
|
+
c.add_folder Path.dir/"webspicy"
|
12
9
|
end
|
10
|
+
Webspicy::Checker.new(config).call
|
11
|
+
end
|
13
12
|
|
14
|
-
|
13
|
+
namespace :test do
|
14
|
+
desc "Run all tests directly on Sinatra application using rack/test"
|
15
|
+
task :rack do
|
15
16
|
config = Webspicy::Configuration.new do |c|
|
16
17
|
c.add_folder Path.dir/"webspicy"
|
17
18
|
c.client = Webspicy::RackTestClient.for(::Sinatra::Application)
|
@@ -22,7 +23,8 @@ namespace :webspicy do
|
|
22
23
|
Webspicy::Tester.new(config).call
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
+
desc "Runs all tests on the real web server (must be launched previously)"
|
27
|
+
task :real do
|
26
28
|
config = Webspicy::Configuration.new do |c|
|
27
29
|
c.host = "http://127.0.0.1:4567"
|
28
30
|
c.add_folder Path.dir/"webspicy"
|
@@ -33,8 +35,10 @@ namespace :webspicy do
|
|
33
35
|
end
|
34
36
|
Webspicy::Tester.new(config).call
|
35
37
|
end
|
36
|
-
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
+
desc "Runs all checks and tests"
|
41
|
+
task :test => :check
|
42
|
+
task :test => :"test:rack"
|
43
|
+
|
40
44
|
task :default => :test
|
data/examples/restful/app.rb
CHANGED
@@ -55,3 +55,16 @@ get '/todo/:id' do |id|
|
|
55
55
|
todo.to_json
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
delete '/todo/:id' do |id|
|
60
|
+
content_type :json
|
61
|
+
todo = settings.todolist.find{|todo| todo[:id] == Integer(id) }
|
62
|
+
if todo.nil?
|
63
|
+
status 404
|
64
|
+
{error: "No such todo"}.to_json
|
65
|
+
else
|
66
|
+
settings.todolist = settings.todolist.reject{|todo| todo[:id] == Integer(id) }
|
67
|
+
status 204
|
68
|
+
content_type "text/plain"
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
name: |-
|
3
|
+
Todo
|
4
|
+
|
5
|
+
url: |-
|
6
|
+
/todo/{id}
|
7
|
+
|
8
|
+
services:
|
9
|
+
- method: |-
|
10
|
+
DELETE
|
11
|
+
|
12
|
+
description: |-
|
13
|
+
Deletes a single todo item
|
14
|
+
|
15
|
+
preconditions: |-
|
16
|
+
|
17
|
+
input_schema: |-
|
18
|
+
{
|
19
|
+
id: Integer
|
20
|
+
}
|
21
|
+
|
22
|
+
output_schema: |-
|
23
|
+
.
|
24
|
+
|
25
|
+
error_schema: |-
|
26
|
+
{
|
27
|
+
error: String
|
28
|
+
}
|
29
|
+
|
30
|
+
examples:
|
31
|
+
|
32
|
+
- description: |-
|
33
|
+
when requested on an existing TODO
|
34
|
+
params:
|
35
|
+
id: 1
|
36
|
+
expected:
|
37
|
+
content_type: ~
|
38
|
+
status: 204
|
39
|
+
|
40
|
+
counterexamples:
|
41
|
+
|
42
|
+
- description: |-
|
43
|
+
when requested on an unexisting TODO
|
44
|
+
params:
|
45
|
+
id: 999254654
|
46
|
+
expected:
|
47
|
+
content_type: application/json
|
48
|
+
status: 404
|
49
|
+
assert:
|
50
|
+
- "pathFD('', error: 'No such todo')"
|
@@ -56,6 +56,15 @@ module Webspicy
|
|
56
56
|
Webspicy.debug("Response: #{@last_response.body}")
|
57
57
|
end
|
58
58
|
|
59
|
+
def delete(url, params = {}, headers = nil)
|
60
|
+
Webspicy.info("DELETE #{url} -- #{params.inspect}")
|
61
|
+
|
62
|
+
@last_response = HTTP[headers || {}].delete(url, body: params.to_json)
|
63
|
+
|
64
|
+
Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
|
65
|
+
Webspicy.debug("Response: #{@last_response.body}")
|
66
|
+
end
|
67
|
+
|
59
68
|
end
|
60
69
|
|
61
70
|
end
|
@@ -91,6 +91,17 @@ module Webspicy
|
|
91
91
|
Webspicy.debug("Response: #{@last_response.body}")
|
92
92
|
end
|
93
93
|
|
94
|
+
def delete(url, params = {}, headers = nil)
|
95
|
+
Webspicy.info("DELETE #{url} -- #{params.inspect}")
|
96
|
+
|
97
|
+
install_headers(headers) if headers
|
98
|
+
handler.delete(url, params.to_json, {"CONTENT_TYPE" => "application/json"})
|
99
|
+
@last_response = handler.last_response
|
100
|
+
|
101
|
+
Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
|
102
|
+
Webspicy.debug("Response: #{@last_response.body}")
|
103
|
+
end
|
104
|
+
|
94
105
|
private
|
95
106
|
|
96
107
|
def install_headers(hs)
|
data/lib/webspicy/formaldoc.fio
CHANGED
@@ -58,8 +58,12 @@ module Webspicy
|
|
58
58
|
def expected_content_type_unmet
|
59
59
|
ect = test_case.expected_content_type
|
60
60
|
got = response.content_type
|
61
|
-
got = got.mime_type
|
62
|
-
ect
|
61
|
+
got = got.mime_type if got.respond_to?(:mime_type)
|
62
|
+
if ect.nil?
|
63
|
+
got.nil? ? nil : "#{ect} != #{got}"
|
64
|
+
else
|
65
|
+
ect.to_s == got.to_s ? nil : "#{ect} != #{got}"
|
66
|
+
end
|
63
67
|
end
|
64
68
|
|
65
69
|
def meets_expected_content_type?
|
data/lib/webspicy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webspicy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- examples/restful/Rakefile
|
124
124
|
- examples/restful/app.rb
|
125
125
|
- examples/restful/webspicy/schema.fio
|
126
|
+
- examples/restful/webspicy/todo/deleteTodo.yml
|
126
127
|
- examples/restful/webspicy/todo/getTodo.yml
|
127
128
|
- examples/restful/webspicy/todo/getTodos.yml
|
128
129
|
- examples/restful/webspicy/todo/postTodos.yml
|