Commit 672d539
Changed files (3)
lib
scim
kit
spec
scim
kit
lib/scim/kit/resource.rb
@@ -1,13 +1,34 @@
module Scim
module Kit
class Resource
+ attr_accessor :id
+ attr_accessor :name
+ attr_accessor :description
+ attr_accessor :endpoint
+ attr_accessor :schema
+ attr_reader :location
+
+ def initialize(location:)
+ @location = location
+ end
+
def to_json
JSON.generate(to_h)
end
def to_h
{
- schemas: [Schema::RESOURCE_TYPE]
+ meta: {
+ resourceType: 'ResourceType',
+ location: location,
+ },
+ schemas: [Schema::RESOURCE_TYPE],
+ id: id,
+ name: name,
+ description: description,
+ endpoint: endpoint,
+ schema: schema,
+ schemaExtensions: [],
}
end
end
spec/scim/kit/resource_spec.rb
@@ -1,17 +1,24 @@
RSpec.describe Scim::Kit::Resource do
- subject { described_class.new }
+ subject { described_class.new(location: location) }
+ let(:location) { FFaker::Internet.uri('https') }
before do
- #subject.id = "Group"
- #subject.meta.location = "https://www.example.org/scim/v2/resource_types/Group"
- #subject.description = "Group"
- #subject.endpoint = "https://www.example.org/scim/v2/groups"
- #subject.name = "Group"
- #subject.schema Scim::Kit::Schema::Group
- #subject.schema_extensions = []
+ subject.id = "Group"
+ subject.description = "Group"
+ subject.endpoint = "https://www.example.org/scim/v2/groups"
+ subject.name = "Group"
+ subject.schema = Scim::Kit::Schema::GROUP
end
let(:hash) { JSON.parse(subject.to_json, symbolize_names: true) }
+ specify { expect(hash[:meta][:location]).to eql(location) }
+ specify { expect(hash[:meta][:resourceType]).to eql('ResourceType') }
specify { expect(hash[:schemas]).to match_array([Scim::Kit::Schema::RESOURCE_TYPE]) }
+ specify { expect(hash[:id]).to eql('Group') }
+ specify { expect(hash[:description]).to eql(subject.description) }
+ specify { expect(hash[:endpoint]).to eql(subject.endpoint) }
+ specify { expect(hash[:name]).to eql(subject.name) }
+ specify { expect(hash[:schema]).to eql(subject.schema) }
+ specify { expect(hash[:schemaExtensions]).to match_array([]) }
end
spec/spec_helper.rb
@@ -2,6 +2,7 @@
require 'bundler/setup'
require 'scim/kit'
+require 'ffaker'
require 'json'
RSpec.configure do |config|