webspicy 0.15.2 → 0.15.3
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/lib/webspicy/configuration.rb +10 -10
- data/lib/webspicy/resource/service.rb +3 -4
- data/lib/webspicy/resource/service/invocation.rb +26 -0
- data/lib/webspicy/resource/service/test_case.rb +13 -1
- data/lib/webspicy/scope.rb +4 -5
- data/lib/webspicy/tester.rb +7 -22
- data/lib/webspicy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d510f36443e5ef38eaabf4c09c6286c1e1aa556a9bb67fd5f5b67303b1faef4c
|
4
|
+
data.tar.gz: bb8b064c714f10bef673d6e61fa0fe71037d8b0e0f8479a4bdb874bbce5484e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dce79c2eba1d8fa74408280cabc8d06eee163fc4f1e8d5b8dfbfb1d4f167063dba68c54a0b1f18d4a72ac2ae88baa5f1a169f9f54b9073cce2c1174efd0b02a8
|
7
|
+
data.tar.gz: b0665863864804a9977c73f25eb22d12930cf623e0db3bf67ea07a15d81162434ecf0e5cf1c12007abba6a6d1ea37f8fdb91cb99afa82893fd4e0b15c7d98ec6
|
@@ -249,36 +249,36 @@ module Webspicy
|
|
249
249
|
# Installs a listener that will be called before all tests
|
250
250
|
#
|
251
251
|
# The `listener` must respond to `call`.
|
252
|
-
def before_all(&listener)
|
253
|
-
register_listener(:before_all, listener)
|
252
|
+
def before_all(l = nil, &listener)
|
253
|
+
register_listener(:before_all, l || listener)
|
254
254
|
end
|
255
255
|
|
256
256
|
# Installs a listener that will be called before each web service invocation.
|
257
257
|
#
|
258
258
|
# The `listener` must respond to `call`.
|
259
|
-
def before_each(&listener)
|
260
|
-
register_listener(:before_each, listener)
|
259
|
+
def before_each(l = nil, &listener)
|
260
|
+
register_listener(:before_each, l || listener)
|
261
261
|
end
|
262
262
|
|
263
263
|
# Installs a listener that will be called after all tests
|
264
264
|
#
|
265
265
|
# The `listener` must respond to `call`.
|
266
|
-
def after_all(&listener)
|
267
|
-
register_listener(:after_all, listener)
|
266
|
+
def after_all(l = nil, &listener)
|
267
|
+
register_listener(:after_all, l || listener)
|
268
268
|
end
|
269
269
|
|
270
270
|
# Installs a listener that will be called after each web service invocation.
|
271
271
|
#
|
272
272
|
# The `listener` must respond to `call`.
|
273
|
-
def after_each(&listener)
|
274
|
-
register_listener(:after_each, listener)
|
273
|
+
def after_each(l = nil, &listener)
|
274
|
+
register_listener(:after_each, l || listener)
|
275
275
|
end
|
276
276
|
|
277
277
|
# Installs a listener that will be called around each web service invocation.
|
278
278
|
#
|
279
279
|
# The `listener` must respond to `call`.
|
280
|
-
def around_each(&listener)
|
281
|
-
register_listener(:around_each, listener)
|
280
|
+
def around_each(l = nil, &listener)
|
281
|
+
register_listener(:around_each, l || listener)
|
282
282
|
end
|
283
283
|
|
284
284
|
# Installs a listener that will be called right after all precondition
|
@@ -51,8 +51,7 @@ module Webspicy
|
|
51
51
|
preconditions.map{|pre|
|
52
52
|
pre.counterexamples(self).map{|tc|
|
53
53
|
tc = Webspicy.test_case(tc, Webspicy.current_scope)
|
54
|
-
tc.
|
55
|
-
tc
|
54
|
+
tc.bind(self, true)
|
56
55
|
}
|
57
56
|
}.flatten
|
58
57
|
end
|
@@ -107,13 +106,13 @@ module Webspicy
|
|
107
106
|
|
108
107
|
def bind_examples
|
109
108
|
(@raw[:examples] ||= []).each do |ex|
|
110
|
-
ex.
|
109
|
+
ex.bind(self, false)
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
114
113
|
def bind_counterexamples
|
115
114
|
(@raw[:counterexamples] ||= []).each do |ex|
|
116
|
-
ex.
|
115
|
+
ex.bind(self, true)
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|
@@ -12,6 +12,32 @@ module Webspicy
|
|
12
12
|
|
13
13
|
attr_reader :service, :test_case, :response, :client
|
14
14
|
|
15
|
+
def errors
|
16
|
+
@errors ||= begin
|
17
|
+
errs = [
|
18
|
+
[:expected_status_unmet, true],
|
19
|
+
[:expected_content_type_unmet, !test_case.is_expected_status?(204)],
|
20
|
+
[:expected_headers_unmet, test_case.has_expected_headers?],
|
21
|
+
[:expected_schema_unmet, !test_case.is_expected_status?(204)],
|
22
|
+
[:assertions_unmet, test_case.has_assertions?],
|
23
|
+
[:postconditions_unmet, test_case.service.has_postconditions? && !test_case.counterexample?],
|
24
|
+
[:expected_error_unmet, test_case.has_expected_error?]
|
25
|
+
].map do |(expectation,only_if)|
|
26
|
+
next unless only_if
|
27
|
+
begin
|
28
|
+
self.send(expectation)
|
29
|
+
rescue => ex
|
30
|
+
ex.message
|
31
|
+
end
|
32
|
+
end
|
33
|
+
errs.compact
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def has_error?
|
38
|
+
!errors.empty?
|
39
|
+
end
|
40
|
+
|
15
41
|
### Getters on response
|
16
42
|
|
17
43
|
def response_code
|
@@ -5,8 +5,20 @@ module Webspicy
|
|
5
5
|
|
6
6
|
def initialize(raw)
|
7
7
|
@raw = raw
|
8
|
+
@counterexample = nil
|
9
|
+
end
|
10
|
+
attr_reader :service
|
11
|
+
attr_reader :counterexample
|
12
|
+
|
13
|
+
def bind(service, counterexample)
|
14
|
+
@service = service
|
15
|
+
@counterexample = counterexample
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def counterexample?
|
20
|
+
!!@counterexample
|
8
21
|
end
|
9
|
-
attr_accessor :service
|
10
22
|
|
11
23
|
def resource
|
12
24
|
service.resource
|
data/lib/webspicy/scope.rb
CHANGED
@@ -48,20 +48,20 @@ module Webspicy
|
|
48
48
|
|
49
49
|
def each_example(service)
|
50
50
|
service.examples.select(&to_filter_proc(config.test_case_filter)).each{|e|
|
51
|
-
yield(expand_example(service, e)
|
51
|
+
yield(expand_example(service, e))
|
52
52
|
}
|
53
53
|
end
|
54
54
|
|
55
55
|
def each_counterexamples(service, &bl)
|
56
56
|
service.counterexamples.select(&to_filter_proc(config.test_case_filter)).each{|e|
|
57
|
-
yield(expand_example(service, e)
|
57
|
+
yield(expand_example(service, e))
|
58
58
|
} if config.run_counterexamples?
|
59
59
|
end
|
60
60
|
|
61
61
|
def each_generated_counterexamples(service, &bl)
|
62
62
|
Webspicy.with_scope(self) do
|
63
63
|
service.generated_counterexamples.select(&to_filter_proc(config.test_case_filter)).each{|e|
|
64
|
-
yield(expand_example(service, e)
|
64
|
+
yield(expand_example(service, e))
|
65
65
|
}
|
66
66
|
end if config.run_counterexamples?
|
67
67
|
end
|
@@ -128,8 +128,7 @@ module Webspicy
|
|
128
128
|
h1 = service.default_example.to_info
|
129
129
|
h2 = example.to_info
|
130
130
|
ex = Resource::Service::TestCase.new(merge_maps(h1, h2))
|
131
|
-
ex.service
|
132
|
-
ex
|
131
|
+
ex.bind(service, example.counterexample?)
|
133
132
|
end
|
134
133
|
|
135
134
|
def merge_maps(h1, h2)
|
data/lib/webspicy/tester.rb
CHANGED
@@ -45,16 +45,16 @@ module Webspicy
|
|
45
45
|
|
46
46
|
def rspec_service!(on, service, client, scope)
|
47
47
|
on.describe service do
|
48
|
-
scope.each_testcase(service) do |test_case
|
48
|
+
scope.each_testcase(service) do |test_case|
|
49
49
|
describe test_case do
|
50
|
-
include_examples 'a successful test case invocation', client, test_case
|
50
|
+
include_examples 'a successful test case invocation', client, test_case
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def rspec_config!
|
57
|
-
RSpec.shared_examples "a successful test case invocation" do |client, test_case
|
57
|
+
RSpec.shared_examples "a successful test case invocation" do |client, test_case|
|
58
58
|
|
59
59
|
around(:each) do |example|
|
60
60
|
client.around(test_case) do
|
@@ -63,7 +63,8 @@ module Webspicy
|
|
63
63
|
client.instrument(test_case)
|
64
64
|
@invocation = client.call(test_case)
|
65
65
|
example.run
|
66
|
-
client.after(test_case)
|
66
|
+
client.after(test_case, @invocation)
|
67
|
+
@invocation
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
@@ -73,24 +74,8 @@ module Webspicy
|
|
73
74
|
|
74
75
|
it 'works' do
|
75
76
|
raise "Test not ran" unless invocation.done?
|
76
|
-
|
77
|
-
|
78
|
-
[:expected_content_type_unmet, !test_case.is_expected_status?(204)],
|
79
|
-
[:expected_headers_unmet, test_case.has_expected_headers?],
|
80
|
-
[:expected_schema_unmet, !test_case.is_expected_status?(204)],
|
81
|
-
[:assertions_unmet, test_case.has_assertions?],
|
82
|
-
[:postconditions_unmet, test_case.service.has_postconditions? && !counterexample],
|
83
|
-
[:expected_error_unmet, test_case.has_expected_error?]
|
84
|
-
].map do |(expectation,only_if)|
|
85
|
-
next unless only_if
|
86
|
-
begin
|
87
|
-
invocation.send(expectation)
|
88
|
-
rescue => ex
|
89
|
-
ex.message
|
90
|
-
end
|
91
|
-
end
|
92
|
-
fails = fails.compact
|
93
|
-
raise "\n* " + fails.join("\n* ") + "\n" unless fails.empty?
|
77
|
+
errors = invocation.errors
|
78
|
+
raise "\n* " + errors.join("\n* ") + "\n" unless errors.empty?
|
94
79
|
end
|
95
80
|
end
|
96
81
|
end
|
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.3
|
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-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|