schemata-router 0.0.1.beta10 → 0.0.1.beta11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/schemata/common/componentbase.rb +9 -6
- data/lib/schemata/common/msgtypebase.rb +8 -5
- data/lib/schemata/router/version.rb +1 -1
- data/spec/common/componentbase_spec.rb +18 -0
- data/spec/common/msgtypebase_spec.rb +16 -0
- data/spec/support/component_helpers.rb +3 -7
- data/spec/support/message_helpers.rb +2 -6
- metadata +5 -1
@@ -27,15 +27,18 @@ module Schemata
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def require_message_classes
|
30
|
-
path =
|
31
|
-
|
32
|
-
|
30
|
+
path = [
|
31
|
+
File.expand_path("../../", __FILE__),
|
32
|
+
"/",
|
33
|
+
Schemata::Helpers.decamelize(component_name),
|
34
|
+
"/*.rb"
|
35
|
+
].join
|
33
36
|
Dir.glob(path, &method(:require))
|
34
37
|
end
|
35
38
|
|
36
|
-
def self.extended(
|
37
|
-
|
38
|
-
|
39
|
+
def self.extended(mod)
|
40
|
+
mod.require_message_classes
|
41
|
+
mod.register_mock_methods
|
39
42
|
end
|
40
43
|
|
41
44
|
end
|
@@ -80,11 +80,14 @@ module Schemata
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def require_message_versions
|
83
|
-
path =
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
path = [
|
84
|
+
File.expand_path("../../", __FILE__),
|
85
|
+
"/",
|
86
|
+
Schemata::Helpers.decamelize(component_name),
|
87
|
+
"/",
|
88
|
+
Schemata::Helpers.decamelize(message_type_name),
|
89
|
+
"/*.rb"
|
90
|
+
].join
|
88
91
|
|
89
92
|
Dir.glob(path, &method(:require))
|
90
93
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'schemata/dea'
|
3
|
+
require 'schemata/common/componentbase'
|
4
|
+
|
5
|
+
describe Schemata::ComponentBase do
|
6
|
+
let(:component) { Schemata::Dea }
|
7
|
+
|
8
|
+
describe '#require_message_classes' do
|
9
|
+
subject { component.require_message_classes }
|
10
|
+
|
11
|
+
it 'require the full path as consumers will need absolute not relative paths' do
|
12
|
+
Dir.should_receive(:glob).with(File.expand_path("../../../lib/schemata/dea/*.rb", __FILE__))
|
13
|
+
subject
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'schemata/dea'
|
3
|
+
require 'schemata/common/msgtypebase'
|
4
|
+
|
5
|
+
describe Schemata::MessageTypeBase do
|
6
|
+
let(:msgtype) { Schemata::Dea::AdvertiseMessage }
|
7
|
+
|
8
|
+
describe '#require_message_versions' do
|
9
|
+
subject { msgtype.require_message_versions }
|
10
|
+
|
11
|
+
it 'require the full path as consumers will need absolute not relative paths' do
|
12
|
+
Dir.should_receive(:glob).with(File.expand_path("../../../lib/schemata/dea/advertise_message/*.rb", __FILE__))
|
13
|
+
subject
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -36,13 +36,9 @@ end
|
|
36
36
|
shared_examples "a mocking method" do |version|
|
37
37
|
|
38
38
|
context "when current_version is #{version}" do
|
39
|
-
before
|
40
|
-
set_current_version(message_type, version)
|
41
|
-
end
|
39
|
+
before { set_current_version(message_type, version) }
|
42
40
|
|
43
|
-
after
|
44
|
-
reset_version(message_type)
|
45
|
-
end
|
41
|
+
after { reset_version(message_type) }
|
46
42
|
|
47
43
|
it "should return a V#{version} object if called with no argument" do
|
48
44
|
msg_obj = component.send(mock_method)
|
@@ -58,7 +54,7 @@ shared_examples "a mocking method" do |version|
|
|
58
54
|
|
59
55
|
it "should raise an error if called with input > #{version}" do
|
60
56
|
expect {
|
61
|
-
|
57
|
+
component.send(mock_method, version + 1)
|
62
58
|
}.to raise_error(NameError)
|
63
59
|
end
|
64
60
|
end
|
@@ -23,14 +23,13 @@ shared_examples "a message" do |msg|
|
|
23
23
|
it "should raise an error if the hash contains incorrect types" do
|
24
24
|
mock_hash = component.send(mock_method, 1).contents
|
25
25
|
first_key = mock_hash.keys[0]
|
26
|
-
first_value = mock_hash[first_key]
|
27
26
|
|
28
27
|
schema = message.schema.schemas[first_key]
|
29
28
|
unallowed_classes = get_unallowed_classes(schema)
|
30
29
|
bad_value = default_value(unallowed_classes.to_a[0])
|
31
30
|
|
32
31
|
expect {
|
33
|
-
|
32
|
+
message.new(first_key => bad_value)
|
34
33
|
}.to raise_error(Schemata::UpdateAttributeError)
|
35
34
|
end
|
36
35
|
|
@@ -75,7 +74,6 @@ shared_examples "a message" do |msg|
|
|
75
74
|
end
|
76
75
|
json_hash.should have_key "min_version"
|
77
76
|
|
78
|
-
data = Schemata::Helpers.deep_copy(json_hash["V#{version}"])
|
79
77
|
1.upto(version) do |i|
|
80
78
|
json_hash.delete("V#{i}")
|
81
79
|
end
|
@@ -111,7 +109,7 @@ shared_examples "a message" do |msg|
|
|
111
109
|
it "should allow nil values during instantiation" do
|
112
110
|
mock_value = component.send(mock_method, version).contents[attr]
|
113
111
|
hash = { attr => mock_value }
|
114
|
-
|
112
|
+
expect { message.new(hash) }.not_to raise_error
|
115
113
|
end
|
116
114
|
|
117
115
|
it "should be able to set the attribute to nil" do
|
@@ -133,8 +131,6 @@ shared_examples "a message" do |msg|
|
|
133
131
|
|
134
132
|
unless msg.schema.schemas[attr].kind_of? Membrane::Schema::Any
|
135
133
|
it "should raise an error if the wrong type is written" do
|
136
|
-
mock_value = component.send(mock_method, version).contents[attr]
|
137
|
-
|
138
134
|
schema = message.schema.schemas[attr]
|
139
135
|
unallowed_classes = get_unallowed_classes(schema)
|
140
136
|
bad_value = default_value(unallowed_classes.to_a[0])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schemata-router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta11
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -130,7 +130,9 @@ files:
|
|
130
130
|
- lib/schemata/router/start_message.rb
|
131
131
|
- lib/schemata/router/version.rb
|
132
132
|
- lib/schemata/router.rb
|
133
|
+
- spec/common/componentbase_spec.rb
|
133
134
|
- spec/common/helpers_spec.rb
|
135
|
+
- spec/common/msgtypebase_spec.rb
|
134
136
|
- spec/common/parsed_msg_spec.rb
|
135
137
|
- spec/spec_helper.rb
|
136
138
|
- spec/support/component_helpers.rb
|
@@ -162,7 +164,9 @@ signing_key:
|
|
162
164
|
specification_version: 3
|
163
165
|
summary: validation for cloundfoundry Router messages
|
164
166
|
test_files:
|
167
|
+
- spec/common/componentbase_spec.rb
|
165
168
|
- spec/common/helpers_spec.rb
|
169
|
+
- spec/common/msgtypebase_spec.rb
|
166
170
|
- spec/common/parsed_msg_spec.rb
|
167
171
|
- spec/spec_helper.rb
|
168
172
|
- spec/support/component_helpers.rb
|