Commit 89213cb
Changed files (1)
spec
scim
kit
spec/scim/kit/v2/resource_spec.rb
@@ -166,18 +166,28 @@ RSpec.describe Scim::Kit::V2::Resource do
specify { expect(subject.as_json.key?(:id)).to be(false) }
specify { expect(subject.as_json.key?(:externalId)).to be(false) }
- context "using a simplified API" do
+ context 'when using a simplified API' do
let(:user_name) { FFaker::Internet.user_name }
+ let(:resource) do
+ described_class.new(schemas: schemas) do |x|
+ x.user_name = user_name
+ x.name.given_name = 'Barbara'
+ x.name.family_name = 'Jensen'
+ x.emails = [
+ { value: FFaker::Internet.email, primary: true },
+ { value: FFaker::Internet.email, primary: false }
+ ]
+ x.locale = 'en'
+ x.timezone = 'Etc/UTC'
+ end
+ end
before do
schema.add_attribute(name: 'userName') do |attribute|
attribute.required = true
attribute.uniqueness = :server
end
- schema.add_attribute(name: 'name') do | attribute|
- attribute.add_attribute(name: 'formatted') do |x|
- x.mutability = :read_only
- end
+ schema.add_attribute(name: 'name') do |attribute|
attribute.add_attribute(name: 'familyName')
attribute.add_attribute(name: 'givenName')
end
@@ -190,20 +200,6 @@ RSpec.describe Scim::Kit::V2::Resource do
end
end
- let(:resource) do
- Scim::Kit::V2::Resource.new(schemas: schemas) do |x|
- x.user_name = user_name
- x.name.given_name = 'Barbara'
- x.name.family_name = 'Jensen'
- x.emails = [
- { value: FFaker::Internet.email, primary: true },
- { value: FFaker::Internet.email, primary: false }
- ]
- x.locale = 'en'
- x.timezone = 'Etc/UTC'
- end
- end
-
specify { expect(resource.user_name).to eql(user_name) }
specify { expect(resource.name.given_name).to eql('Barbara') }
specify { expect(resource.name.family_name).to eql('Jensen') }
@@ -215,6 +211,18 @@ RSpec.describe Scim::Kit::V2::Resource do
specify { expect(resource.timezone).to eql('Etc/UTC') }
specify { expect(resource.to_h[:userName]).to eql(user_name) }
+ specify { expect(resource.to_h[:name][:givenName]).to eql('Barbara') }
+ specify { expect(resource.to_h[:name][:familyName]).to eql('Jensen') }
+ specify { expect(resource.to_h[:emails][0][:value]).to be_present }
+ specify { expect(resource.to_h[:emails][0][:primary]).to be(true) }
+ specify { expect(resource.to_h[:emails][1][:value]).to be_present }
+ specify { expect(resource.to_h[:emails][1][:primary]).to be(false) }
+ specify { expect(resource.to_h[:locale]).to eql('en') }
+ specify { expect(resource.to_h[:timezone]).to eql('Etc/UTC') }
+ specify { expect(resource.to_h.key?(:meta)).to be(false) }
+ specify { expect(resource.to_h.key?(:id)).to be(false) }
+ specify { expect(resource.to_h.key?(:external_id)).to be(false) }
+ specify { puts resource.to_h }
end
end
end