spec/models/scimitar/schema/attribute_spec.rb in scimitar-1.11.0 vs spec/models/scimitar/schema/attribute_spec.rb in scimitar-2.0.0

- old
+ new

@@ -19,12 +19,14 @@ it 'transforms complexTypes into subAttributes' do name = described_class.new(name: 'name', complexType: Scimitar::ComplexTypes::Name) expect(name.type).to eql('complex') expect(name.subAttributes).to eql(Scimitar::Schema::Name.scim_attributes) end + end + context '#valid?' do it 'is invalid if attribute is required but value is blank' do attribute = described_class.new(name: 'userName', type: 'string', required: true) expect(attribute.valid?(nil)).to be(false) expect(attribute.errors.messages.to_h).to eql({userName: ['is required']}) @@ -44,32 +46,10 @@ attribute = described_class.new(name: 'userName', type: 'string') expect(attribute.valid?(10)).to be(false) expect(attribute.errors.messages.to_h).to eql({userName: ['has the wrong type. It has to be a(n) string.']}) end - it 'is valid if multi-valued and type is string and given value is an array of strings' do - attribute = described_class.new(name: 'scopes', multiValued: true, type: 'string') - expect(attribute.valid?(['something', 'something else'])).to be(true) - end - - it 'is valid if multi-valued and type is string and given value is an empty array' do - attribute = described_class.new(name: 'scopes', multiValued: true, type: 'string') - expect(attribute.valid?([])).to be(true) - end - - it 'is invalid if multi-valued and type is string and given value is not an array' do - attribute = described_class.new(name: 'scopes', multiValued: true, type: 'string') - expect(attribute.valid?('something')).to be(false) - expect(attribute.errors.messages.to_h).to eql({scopes: ['or one of its elements has the wrong type. It has to be an array of strings.']}) - end - - it 'is invalid if multi-valued and type is string and given value is an array containing another type' do - attribute = described_class.new(name: 'scopes', multiValued: true, type: 'string') - expect(attribute.valid?(['something', 123])).to be(false) - expect(attribute.errors.messages.to_h).to eql({scopes: ['or one of its elements has the wrong type. It has to be an array of strings.']}) - end - it 'is valid if type is boolean and given value is boolean' do expect(described_class.new(name: 'name', type: 'boolean').valid?(false)).to be(true) expect(described_class.new(name: 'name', type: 'boolean').valid?(true)).to be(true) end @@ -94,6 +74,7 @@ end it 'is not valid if type is dateTime and given value is not a valid date' do expect(described_class.new(name: 'startDate', type: 'dateTime').valid?('gaga')).to be(false) end end + end