Commit e99257b
Changed files (2)
lib
scim
kit
spec
scim
kit
lib/scim/kit/v2.rb
@@ -36,7 +36,9 @@ module Scim
complex: 'complex'
}.freeze
COERCION = {
- binary: ->(x) { Base64.strict_encode64(x) },
+ binary: lambda { |x|
+ VALIDATIONS[:binary].call(x) ? x : Base64.strict_encode64(x)
+ },
boolean: lambda { |x|
return true if x == 'true'
return false if x == 'false'
spec/scim/kit/v2/attribute_type_spec.rb
@@ -157,6 +157,7 @@ RSpec.describe Scim::Kit::V2::AttributeType do
let(:uri) { FFaker::Internet.uri('https') }
specify { expect(described_class.new(name: :x, type: :binary).coerce(raw_image)).to eql(image) }
+ specify { expect(described_class.new(name: :x, type: :binary).coerce(image)).to eql(image) }
specify { expect(described_class.new(name: :x, type: :boolean).coerce(true)).to be(true) }
specify { expect(described_class.new(name: :x, type: :boolean).coerce('true')).to be(true) }