Commit 1df491d

mokha <mokha@cisco.com>
2019-01-14 18:05:45
start the assign_attributes journey
1 parent 73f2b1b
Changed files (2)
lib
scim
spec
scim
lib/scim/kit/v2/resource.rb
@@ -35,6 +35,12 @@ module Scim
           end
         end
 
+        def assign_attributes(attributes = {})
+          attributes.each do |key, value|
+            public_send(:"#{key.to_s.underscore}=", value)
+          end
+        end
+
         private
 
         def schema_validations
spec/scim/kit/v2/resource_spec.rb
@@ -344,4 +344,17 @@ RSpec.describe Scim::Kit::V2::Resource do
       specify { expect(subject).to be_mode(:client) }
     end
   end
+
+  describe '#assign_attributes' do
+    context 'with a simple string attribute' do
+      let(:user_name) { FFaker::Internet.user_name }
+
+      before do
+        schema.add_attribute(name: 'userName')
+        subject.assign_attributes(userName: user_name)
+      end
+
+      specify { expect(subject.user_name).to eql(user_name) }
+    end
+  end
 end