schemata-cloud_controller 0.0.1.beta6 → 0.0.1.beta7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/schemata/cloud_controller/bulk_credentials_response/bulk_credentials_response_v1.rb +2 -2
- data/lib/schemata/cloud_controller/droplet_updated_message/droplet_updated_message_v1.rb +2 -2
- data/lib/schemata/cloud_controller/version.rb +1 -1
- data/lib/schemata/common/componentbase.rb +9 -6
- data/lib/schemata/common/msgtypebase.rb +8 -5
- 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
data/lib/schemata/cloud_controller/bulk_credentials_response/bulk_credentials_response_v1.rb
CHANGED
@@ -13,11 +13,11 @@ module Schemata
|
|
13
13
|
|
14
14
|
define_min_version 1
|
15
15
|
|
16
|
-
define_upvert do |
|
16
|
+
define_upvert do |_|
|
17
17
|
raise NotImplementedError.new
|
18
18
|
end
|
19
19
|
|
20
|
-
define_generate_old_fields do |
|
20
|
+
define_generate_old_fields do |_|
|
21
21
|
raise NotImplementedError.new
|
22
22
|
end
|
23
23
|
|
@@ -15,11 +15,11 @@ module Schemata
|
|
15
15
|
|
16
16
|
define_min_version 1
|
17
17
|
|
18
|
-
define_upvert do |
|
18
|
+
define_upvert do |_|
|
19
19
|
raise NotImplementedError.new
|
20
20
|
end
|
21
21
|
|
22
|
-
define_generate_old_fields do |
|
22
|
+
define_generate_old_fields do |_|
|
23
23
|
raise NotImplementedError.new
|
24
24
|
end
|
25
25
|
|
@@ -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-cloud_controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta7
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -118,7 +118,9 @@ files:
|
|
118
118
|
- lib/schemata/helpers/hash_copy.rb
|
119
119
|
- lib/schemata/helpers/stringify.rb
|
120
120
|
- spec/cloud_controller_spec.rb
|
121
|
+
- spec/common/componentbase_spec.rb
|
121
122
|
- spec/common/helpers_spec.rb
|
123
|
+
- spec/common/msgtypebase_spec.rb
|
122
124
|
- spec/common/parsed_msg_spec.rb
|
123
125
|
- spec/component/aux_data_spec.rb
|
124
126
|
- spec/component/component_bar_spec.rb
|
@@ -160,7 +162,9 @@ specification_version: 3
|
|
160
162
|
summary: validation for cloundfoundry cloud controller messages
|
161
163
|
test_files:
|
162
164
|
- spec/cloud_controller_spec.rb
|
165
|
+
- spec/common/componentbase_spec.rb
|
163
166
|
- spec/common/helpers_spec.rb
|
167
|
+
- spec/common/msgtypebase_spec.rb
|
164
168
|
- spec/common/parsed_msg_spec.rb
|
165
169
|
- spec/component/aux_data_spec.rb
|
166
170
|
- spec/component/component_bar_spec.rb
|