webspicy 0.3.0.pre.rc2 → 0.3.0.pre.rc3
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/checker.rb +2 -3
- data/lib/webspicy/configuration.rb +2 -2
- data/lib/webspicy/scope.rb +1 -1
- data/lib/webspicy/tester.rb +1 -1
- data/lib/webspicy/version.rb +1 -1
- data/lib/webspicy.rb +30 -13
- data/spec/unit/scope/test_each_resource.rb +0 -2
- data/spec/unit/scope/test_each_service.rb +0 -2
- data/spec/unit/spec_helper.rb +0 -14
- data/spec/unit/test_configuration.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b25073c6397b2720a2c7fd0024cb7a0fa5762f57
|
4
|
+
data.tar.gz: 2012c7403444a88649a212d22691e8260d4471c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bd05c8199e926768b3bd197a30df9e0b6da4de007e1abcea0661583ebbfea9b5636a89f65c4e65c1f397adb9c2e1d1142b0e04a9d2ee8f2f4a1f6c9d404e2a0
|
7
|
+
data.tar.gz: 8a7fee06f727727945247b22a508b5d9566e6a2acc3e8fefba2d6b0b1cc8aca3238ad89f874294801e069dc4d82254e6970d1580968515046761cb5cbeb04faf
|
data/lib/webspicy/checker.rb
CHANGED
@@ -8,18 +8,17 @@ module Webspicy
|
|
8
8
|
|
9
9
|
def call
|
10
10
|
config.each_scope do |scope|
|
11
|
-
client = scope.get_client
|
12
11
|
scope.each_resource_file do |file, folder|
|
13
12
|
RSpec.describe file.relative_to(folder).to_s do
|
14
13
|
|
15
14
|
it 'meets the formal doc data schema' do
|
16
|
-
Webspicy.resource(file.load, file)
|
15
|
+
Webspicy.resource(file.load, file, scope)
|
17
16
|
end
|
18
17
|
|
19
18
|
end
|
20
19
|
end
|
21
|
-
RSpec::Core::Runner.run config.rspec_options
|
22
20
|
end
|
21
|
+
RSpec::Core::Runner.run config.rspec_options
|
23
22
|
end
|
24
23
|
|
25
24
|
end
|
@@ -26,7 +26,7 @@ module Webspicy
|
|
26
26
|
config.each_scope(&bl)
|
27
27
|
end
|
28
28
|
else
|
29
|
-
|
29
|
+
yield Scope.new(self)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -228,7 +228,7 @@ module Webspicy
|
|
228
228
|
# original.
|
229
229
|
def dup(&bl)
|
230
230
|
super.tap do |d|
|
231
|
-
d.children =
|
231
|
+
d.children = []
|
232
232
|
d.rspec_options = self.rspec_options.dup
|
233
233
|
d.before_listeners = self.before_listeners.dup
|
234
234
|
yield d if block_given?
|
data/lib/webspicy/scope.rb
CHANGED
data/lib/webspicy/tester.rb
CHANGED
data/lib/webspicy/version.rb
CHANGED
data/lib/webspicy.rb
CHANGED
@@ -38,40 +38,57 @@ module Webspicy
|
|
38
38
|
|
39
39
|
FORMALDOC = Finitio::DEFAULT_SYSTEM.parse (Path.dir/"webspicy/formaldoc.fio").read
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
# Returns a default scope instance.
|
42
|
+
def default_scope
|
43
|
+
Scope.new(Configuration.new)
|
44
|
+
end
|
45
|
+
module_function :default_scope
|
46
|
+
|
47
|
+
def resource(raw, file = nil, scope = default_scope)
|
48
|
+
with_scope(scope) do
|
49
|
+
FORMALDOC["Resource"].dress(raw)
|
50
|
+
end
|
43
51
|
end
|
44
52
|
module_function :resource
|
45
53
|
|
46
|
-
def service(raw)
|
47
|
-
|
54
|
+
def service(raw, scope = default_scope)
|
55
|
+
with_scope(scope) do
|
56
|
+
FORMALDOC["Service"].dress(raw)
|
57
|
+
end
|
48
58
|
end
|
49
59
|
module_function :service
|
50
60
|
|
51
|
-
def test_case(raw)
|
52
|
-
|
61
|
+
def test_case(raw, scope = default_scope)
|
62
|
+
with_scope(scope) do
|
63
|
+
FORMALDOC["TestCase"].dress(raw)
|
64
|
+
end
|
53
65
|
end
|
54
66
|
module_function :test_case
|
55
67
|
|
56
68
|
#
|
57
|
-
# Yields
|
69
|
+
# Yields the block after having installed `scope` globally.
|
58
70
|
#
|
59
71
|
# This method makes sure that the scope will also be accessible for
|
60
72
|
# Finitio world schema parsing/dressing. Given that some global state
|
61
73
|
# is required (see "Schema" ADT, the dresser in particular, which calls
|
62
74
|
# `schema` later), the scope is put as a thread-local variable...
|
63
75
|
#
|
64
|
-
|
65
|
-
|
66
|
-
|
76
|
+
# This method is considered private and should not be used outside of
|
77
|
+
# Webspicy itself.
|
78
|
+
#
|
79
|
+
def with_scope(scope)
|
80
|
+
scope = set_current_scope(scope)
|
81
|
+
result = yield scope
|
67
82
|
set_current_scope(nil)
|
83
|
+
result
|
68
84
|
end
|
69
|
-
module_function :
|
85
|
+
module_function :with_scope
|
70
86
|
|
71
87
|
#
|
72
88
|
# Sets the current scope.
|
73
89
|
#
|
74
|
-
#
|
90
|
+
# This method is considered private and should not be used outside of
|
91
|
+
# Webspicy itself.
|
75
92
|
#
|
76
93
|
def set_current_scope(scope)
|
77
94
|
Thread.current[:webspicy_scope] = scope
|
@@ -80,7 +97,7 @@ module Webspicy
|
|
80
97
|
|
81
98
|
#
|
82
99
|
# Parses a webservice schema (typically input or output) in the context
|
83
|
-
# of the current scope previously installed using `
|
100
|
+
# of the current scope previously installed using `with_scope`.
|
84
101
|
#
|
85
102
|
# If no scope has previously been installed, Finitio's default system
|
86
103
|
# is used instead of another schema.
|
data/spec/unit/spec_helper.rb
CHANGED
@@ -13,20 +13,6 @@ module SpecHelper
|
|
13
13
|
|
14
14
|
end
|
15
15
|
|
16
|
-
module ScopeManagement
|
17
|
-
|
18
|
-
def with_scope_management
|
19
|
-
before(:each) {
|
20
|
-
Webspicy.set_current_scope(scope)
|
21
|
-
}
|
22
|
-
after(:each) {
|
23
|
-
Webspicy.set_current_scope(nil)
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
16
|
RSpec.configure do |c|
|
30
17
|
c.include SpecHelper
|
31
|
-
c.extend ScopeManagement
|
32
18
|
end
|
@@ -112,6 +112,7 @@ module Webspicy
|
|
112
112
|
let(:original) do
|
113
113
|
Configuration.new(Path.dir/'resource') do |c|
|
114
114
|
c.host = "http://127.0.0.1"
|
115
|
+
c.folder 'service'
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
@@ -135,6 +136,11 @@ module Webspicy
|
|
135
136
|
expect(duped.before_listeners.size).to eq(1)
|
136
137
|
expect(original.before_listeners.size).to eq(0)
|
137
138
|
end
|
139
|
+
|
140
|
+
it 'empties the children' do
|
141
|
+
duped = original.dup
|
142
|
+
expect(duped.children).to be_empty
|
143
|
+
end
|
138
144
|
end
|
139
145
|
|
140
146
|
end
|