Comparing changes

v0.2.2 v0.2.3
3 commits 6 files changed

Commits

f55b629 add a pending spec mokha 2019-01-08 16:55:31
fa341a0 extract attribute class mokha 2019-01-08 16:52:32
lib/scim/kit/v2/templates/resource_type.json.jbuilder
@@ -10,4 +10,4 @@ json.name name
 json.description description
 json.endpoint endpoint
 json.schema schema
-json.schema_extensions []
+json.schema_extensions schema_extensions
lib/scim/kit/v2/attributable.rb
@@ -9,10 +9,7 @@ module Scim
 
         def define_attributes_for(types)
           @dynamic_attributes = {}.with_indifferent_access
-          types.each do |type|
-            dynamic_attributes[type.name] = Attribute.new(type: type)
-            extend(create_module_for(type))
-          end
+          types.each { |x| attribute(x) }
         end
 
         private
@@ -44,6 +41,11 @@ module Scim
             end
           end
         end
+
+        def attribute(type)
+          dynamic_attributes[type.name] = Attribute.new(type: type)
+          extend(create_module_for(type))
+        end
       end
     end
   end
lib/scim/kit/v2/resource_type.rb
@@ -12,11 +12,13 @@ module Scim
         attr_accessor :description
         attr_accessor :endpoint
         attr_accessor :schema
+        attr_accessor :schema_extensions
         attr_reader :meta
 
         def initialize(location:)
           @meta = Meta.new('ResourceType', location)
           @meta.version = @meta.created = @meta.last_modified = nil
+          @schema_extensions = []
         end
 
         def self.build(*args)
lib/scim/kit/version.rb
@@ -2,6 +2,6 @@
 
 module Scim
   module Kit
-    VERSION = '0.2.2'
+    VERSION = '0.2.3'
   end
 end
spec/scim/kit/v2/attribute_spec.rb
@@ -192,5 +192,9 @@ RSpec.describe Scim::Kit::V2::Attribute do
 
     specify { expect(subject._value).to match_array([{ value: email, primary: true }, { value: other_email, primary: false }]) }
     specify { expect(subject.as_json[:emails]).to match_array([{ value: email, primary: true }, { value: other_email, primary: false }]) }
+
+    context 'when the hash is invalid' do
+      xspecify { expect { subject._value = [{ blah: 'blah' }] }.to raise_error(ArgumentError) }
+    end
   end
 end
spec/scim/kit/v2/resource_type_spec.rb
@@ -22,4 +22,12 @@ RSpec.describe Scim::Kit::V2::ResourceType do
   specify { expect(subject.to_h[:name]).to eql(subject.name) }
   specify { expect(subject.to_h[:schema]).to eql(subject.schema) }
   specify { expect(subject.to_h[:schemaExtensions]).to match_array([]) }
+
+  context 'with a schema extension' do
+    let(:extension) { 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User' }
+
+    before { subject.schema_extensions.push(extension) }
+
+    specify { expect(subject.to_h[:schemaExtensions]).to match_array([extension]) }
+  end
 end