webspicy 0.11.2 → 0.12.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/webspicy/todo/patchTodo.yml +5 -3
- data/lib/webspicy/formaldoc.fio +5 -4
- data/lib/webspicy/resource/service/test_case.rb +8 -4
- data/lib/webspicy/resource/service.rb +4 -0
- data/lib/webspicy/scope.rb +28 -3
- data/lib/webspicy/version.rb +2 -2
- data/spec/unit/scope/test_expand_example.rb +63 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d78c07ceefb51e2e501878a3c7e85abd6b9497a
|
4
|
+
data.tar.gz: 027aec45632f053e971203a2d8b6ab5d1b20fa9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebb4af1b2860f2569c18d282b9fcf2c367b6465411f57d7c01848100118412267876f68cf520b2c537610c1435aa78d4304cefdc0f2f3c9ac09ec0b91f644937
|
7
|
+
data.tar.gz: b743850dc46e00e2e3e2a077e028a6d352a0c378492c34fd471346f3586e0407a309aab1dd4127ff1c5a0625bf8d189068839dbb7cab5de6443c57f6909d015a
|
@@ -24,6 +24,11 @@ services:
|
|
24
24
|
error_schema: |-
|
25
25
|
ErrorSchema
|
26
26
|
|
27
|
+
default_example:
|
28
|
+
expected:
|
29
|
+
content_type: application/json
|
30
|
+
status: 200
|
31
|
+
|
27
32
|
examples:
|
28
33
|
|
29
34
|
- description: |-
|
@@ -31,9 +36,6 @@ services:
|
|
31
36
|
params:
|
32
37
|
id: 1
|
33
38
|
description: 'hello world'
|
34
|
-
expected:
|
35
|
-
content_type: application/json
|
36
|
-
status: 200
|
37
39
|
assert:
|
38
40
|
- "pathFD('', description: 'hello world')"
|
39
41
|
|
data/lib/webspicy/formaldoc.fio
CHANGED
@@ -30,13 +30,14 @@ Service =
|
|
30
30
|
output_schema : Schema
|
31
31
|
error_schema : Schema
|
32
32
|
blackbox :? String
|
33
|
+
default_example :? TestCase
|
33
34
|
examples :? [TestCase]
|
34
35
|
counterexamples :? [TestCase]
|
35
36
|
}
|
36
37
|
|
37
38
|
TestCase =
|
38
39
|
.Webspicy::Resource::Service::TestCase <info> {
|
39
|
-
description
|
40
|
+
description :? String
|
40
41
|
dress_params :? Boolean
|
41
42
|
params :? Params
|
42
43
|
headers :? .Hash
|
@@ -45,13 +46,13 @@ TestCase =
|
|
45
46
|
seeds :? String
|
46
47
|
requester :? String
|
47
48
|
metadata :? { ...: .Object }
|
48
|
-
expected
|
49
|
-
status
|
49
|
+
expected :? {
|
50
|
+
status :? Integer
|
50
51
|
content_type :? String|Nil
|
51
52
|
error :? String
|
52
53
|
headers :? .Hash
|
53
54
|
}
|
54
|
-
assert
|
55
|
+
assert :? [String]
|
55
56
|
}
|
56
57
|
|
57
58
|
Params = .Array|.Hash
|
@@ -53,16 +53,20 @@ module Webspicy
|
|
53
53
|
file_upload ? file_upload.locate(resource) : nil
|
54
54
|
end
|
55
55
|
|
56
|
+
def expected
|
57
|
+
@raw[:expected] || {}
|
58
|
+
end
|
59
|
+
|
56
60
|
def expected_content_type
|
57
|
-
|
61
|
+
expected.fetch(:content_type){ 'application/json' }
|
58
62
|
end
|
59
63
|
|
60
64
|
def expected_status
|
61
|
-
|
65
|
+
expected[:status]
|
62
66
|
end
|
63
67
|
|
64
68
|
def expected_error
|
65
|
-
|
69
|
+
expected[:error]
|
66
70
|
end
|
67
71
|
|
68
72
|
def has_expected_error?
|
@@ -70,7 +74,7 @@ module Webspicy
|
|
70
74
|
end
|
71
75
|
|
72
76
|
def expected_headers
|
73
|
-
|
77
|
+
expected[:headers] || {}
|
74
78
|
end
|
75
79
|
|
76
80
|
def has_expected_headers?
|
data/lib/webspicy/scope.rb
CHANGED
@@ -47,16 +47,22 @@ module Webspicy
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def each_example(service)
|
50
|
-
service.examples.each{|
|
50
|
+
service.examples.each{|e|
|
51
|
+
yield(expand_example(service, e), false)
|
52
|
+
}
|
51
53
|
end
|
52
54
|
|
53
55
|
def each_counterexamples(service, &bl)
|
54
|
-
service.counterexamples.each{|
|
56
|
+
service.counterexamples.each{|e|
|
57
|
+
yield(expand_example(service, e), true)
|
58
|
+
} if config.run_counterexamples?
|
55
59
|
end
|
56
60
|
|
57
61
|
def each_generated_counterexamples(service, &bl)
|
58
62
|
Webspicy.with_scope(self) do
|
59
|
-
service.generated_counterexamples.each{|
|
63
|
+
service.generated_counterexamples.each{|e|
|
64
|
+
yield(expand_example(service, e), true)
|
65
|
+
}
|
60
66
|
end if config.run_counterexamples?
|
61
67
|
end
|
62
68
|
|
@@ -117,6 +123,25 @@ module Webspicy
|
|
117
123
|
|
118
124
|
private
|
119
125
|
|
126
|
+
def expand_example(service, example)
|
127
|
+
return example unless service.default_example
|
128
|
+
h1 = service.default_example.to_info
|
129
|
+
h2 = example.to_info
|
130
|
+
ex = Resource::Service::TestCase.new(merge_maps(h1, h2))
|
131
|
+
ex.service = service
|
132
|
+
ex
|
133
|
+
end
|
134
|
+
|
135
|
+
def merge_maps(h1, h2)
|
136
|
+
h1.merge(h2) do |k,v1,v2|
|
137
|
+
case v1
|
138
|
+
when Hash then merge_maps(v1, v2)
|
139
|
+
when Array then v1 + v2
|
140
|
+
else v2
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
120
145
|
# Returns a proc that implements file_filter strategy according to the
|
121
146
|
# type of filter installed
|
122
147
|
def to_filter_proc(filter)
|
data/lib/webspicy/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Webspicy
|
3
|
+
describe Scope, "expand_example" do
|
4
|
+
|
5
|
+
subject{ Scope.new({}).send(:expand_example, service, example) }
|
6
|
+
|
7
|
+
context 'when the service has no default example' do
|
8
|
+
let(:service) {
|
9
|
+
Webspicy.service({
|
10
|
+
method: "GET",
|
11
|
+
description: "Test service",
|
12
|
+
preconditions: "Foo",
|
13
|
+
input_schema: "{ id: Integer }",
|
14
|
+
output_schema: "{}",
|
15
|
+
error_schema: "{}"
|
16
|
+
})
|
17
|
+
}
|
18
|
+
|
19
|
+
let(:example) {
|
20
|
+
Webspicy.test_case({
|
21
|
+
description: "Hello world"
|
22
|
+
})
|
23
|
+
}
|
24
|
+
|
25
|
+
it 'returns the example itself' do
|
26
|
+
expect(subject).to be(example)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when the service has a default example' do
|
31
|
+
let(:service) {
|
32
|
+
Webspicy.service({
|
33
|
+
method: "GET",
|
34
|
+
description: "Test service",
|
35
|
+
preconditions: "Foo",
|
36
|
+
input_schema: "{ id: Integer }",
|
37
|
+
output_schema: "{}",
|
38
|
+
error_schema: "{}",
|
39
|
+
default_example: {
|
40
|
+
expected: { status: 200 }
|
41
|
+
}
|
42
|
+
})
|
43
|
+
}
|
44
|
+
|
45
|
+
let(:example) {
|
46
|
+
Webspicy.test_case({
|
47
|
+
description: "Hello world",
|
48
|
+
expected: { content_type: "application/json" }
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
it 'deep merges the default example and the example as expected' do
|
53
|
+
expect(subject).to be_a(Resource::Service::TestCase)
|
54
|
+
expect(subject.description).to eql("Hello world")
|
55
|
+
expect(subject.expected).to eql({
|
56
|
+
status: 200,
|
57
|
+
content_type: "application/json"
|
58
|
+
})
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end # module Webspicy
|
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.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- spec/unit/resource/test_url_placeholders.rb
|
196
196
|
- spec/unit/scope/test_each_resource.rb
|
197
197
|
- spec/unit/scope/test_each_service.rb
|
198
|
+
- spec/unit/scope/test_expand_example.rb
|
198
199
|
- spec/unit/scope/test_to_real_url.rb
|
199
200
|
- spec/unit/spec_helper.rb
|
200
201
|
- spec/unit/test_configuration.rb
|
@@ -221,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
222
|
version: '0'
|
222
223
|
requirements: []
|
223
224
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.
|
225
|
+
rubygems_version: 2.6.11
|
225
226
|
signing_key:
|
226
227
|
specification_version: 4
|
227
228
|
summary: Webspicy helps testing web services as software operation black boxes!
|