schemata-health_manager 0.0.1.beta6 → 0.0.1.beta7

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.
@@ -27,15 +27,18 @@ module Schemata
27
27
  end
28
28
 
29
29
  def require_message_classes
30
- path = "./lib/schemata/"
31
- path << Schemata::Helpers.decamelize(component_name)
32
- path << "/*.rb"
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(klass)
37
- klass.require_message_classes
38
- klass.register_mock_methods
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 = "./lib/schemata/"
84
- path << Schemata::Helpers.decamelize(component_name)
85
- path << "/"
86
- path << Schemata::Helpers.decamelize(message_type_name)
87
- path << "/*.rb"
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
@@ -1,5 +1,5 @@
1
1
  module Schemata
2
2
  module HealthManager
3
- VERSION = "0.0.1.beta6"
3
+ VERSION = "0.0.1.beta7"
4
4
  end
5
5
  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 :each do
40
- set_current_version(message_type, version)
41
- end
39
+ before { set_current_version(message_type, version) }
42
40
 
43
- after :each do
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
- msg_obj = component.send(mock_method, version + 1)
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
- msg_obj = message.new({first_key => bad_value})
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
- msg_obj = message.new(hash)
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-health_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta6
4
+ version: 0.0.1.beta7
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -136,7 +136,9 @@ files:
136
136
  - lib/schemata/helpers/hash_copy.rb
137
137
  - lib/schemata/helpers/stringify.rb
138
138
  - spec/cloud_controller_spec.rb
139
+ - spec/common/componentbase_spec.rb
139
140
  - spec/common/helpers_spec.rb
141
+ - spec/common/msgtypebase_spec.rb
140
142
  - spec/common/parsed_msg_spec.rb
141
143
  - spec/component/aux_data_spec.rb
142
144
  - spec/component/component_bar_spec.rb
@@ -178,7 +180,9 @@ specification_version: 3
178
180
  summary: validation for cloundfoundry health manager messages
179
181
  test_files:
180
182
  - spec/cloud_controller_spec.rb
183
+ - spec/common/componentbase_spec.rb
181
184
  - spec/common/helpers_spec.rb
185
+ - spec/common/msgtypebase_spec.rb
182
186
  - spec/common/parsed_msg_spec.rb
183
187
  - spec/component/aux_data_spec.rb
184
188
  - spec/component/component_bar_spec.rb