schemata-router 0.0.1.beta8 → 0.0.1.beta9
Sign up to get free protection for your applications and to get access to all the features.
data/spec/support/helpers.rb
CHANGED
@@ -53,6 +53,10 @@ def num_mandatory_fields(msg_obj)
|
|
53
53
|
return diff.size
|
54
54
|
end
|
55
55
|
|
56
|
+
def all_classes
|
57
|
+
all_classes = Set.new([Integer, String, Float, TrueClass, FalseClass, NilClass, Hash, Array])
|
58
|
+
end
|
59
|
+
|
56
60
|
def get_allowed_classes(schema)
|
57
61
|
case schema
|
58
62
|
when Membrane::Schema::Bool
|
@@ -65,11 +69,12 @@ def get_allowed_classes(schema)
|
|
65
69
|
return Set.new([Hash])
|
66
70
|
when Membrane::Schema::List
|
67
71
|
return Set.new([Array])
|
72
|
+
when Membrane::Schema::Value
|
73
|
+
return Set.new([schema.value.class])
|
68
74
|
end
|
69
75
|
end
|
70
76
|
|
71
77
|
def get_unallowed_classes(schema)
|
72
|
-
all_classes = Set.new([Integer, String, Float, TrueClass, FalseClass, NilClass, Hash, Array])
|
73
78
|
allowed_classes = get_allowed_classes(schema)
|
74
79
|
all_classes - allowed_classes
|
75
80
|
end
|
@@ -44,6 +44,18 @@ shared_examples "a message" do
|
|
44
44
|
msg_obj = message.new({first_key => bad_value})
|
45
45
|
}.to raise_error(Schemata::UpdateAttributeError)
|
46
46
|
end
|
47
|
+
|
48
|
+
it "should stringify keys when they are symbols" do
|
49
|
+
mock_hash = component.send(mock_method, 1).contents
|
50
|
+
first_key = mock_hash.keys[0]
|
51
|
+
first_value = mock_hash[first_key]
|
52
|
+
|
53
|
+
input_hash = {
|
54
|
+
first_key.to_sym => first_value
|
55
|
+
}
|
56
|
+
msg_obj = message.new(input_hash)
|
57
|
+
msg_obj.send(first_key).should_not be_nil
|
58
|
+
end
|
47
59
|
end
|
48
60
|
|
49
61
|
describe "#encode" do
|