Commit e4a620d

mokha <mokha@cisco.com>
2019-01-12 17:45:42
default multi_valued to array
1 parent 0ab2480
Changed files (2)
lib
scim
spec
lib/scim/kit/v2/attribute.rb
@@ -18,7 +18,7 @@ module Scim
 
         def initialize(resource:, type:, value: nil)
           @type = type
-          @_value = value
+          @_value = value || type.multi_valued ? [] : nil
           @_resource = resource
           define_attributes_for(resource, type.attributes)
         end
spec/scim/kit/v2/attribute_spec.rb
@@ -20,12 +20,13 @@ RSpec.describe Scim::Kit::V2::Attribute do
     end
 
     context 'when multiple values are allowed' do
-      before do
-        type.multi_valued = true
+      before { type.multi_valued = true }
+
+      specify { expect(subject._value).to match_array([]) }
+      specify do
         subject._value = %w[superman batman]
+        expect(subject._value).to match_array(%w[superman batman])
       end
-
-      specify { expect(subject._value).to match_array(%w[superman batman]) }
     end
 
     context 'when a single value is provided' do