Skip to content

Commit

Permalink
added spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiobayona committed May 17, 2024
1 parent 935fc08 commit 938d2e8
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions spec/easy_talk/property_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,67 @@
end

# unsure if this should be supported
context 'with a plain class as the array item' do
context 'with a model' do
let(:custom_class) do
Class.new do
include EasyTalk::Model

def self.name
'CustomClass'
end

define_schema do
property :name, String
end
end
end

pending 'returns an array of custom class type' do
prop = described_class.new(:name, T::Array[custom_class]).build
expect(prop).to eq(type: 'array', items: { type: 'object' })
context 'when the model is an array item' do
it 'returns an array of custom class type' do
prop = described_class.new(:name, T::Array[custom_class]).as_json
expect(prop).to include_json({
'type': 'array',
"items": {
"type": 'object',
"properties": {
"name": {
"type": 'string'
}
},
"required": ['name']
}
})
end
end

context 'when the model is a property' do
it 'returns a custom class type' do
prop = described_class.new(:name, custom_class).as_json
expect(prop).to include_json({
'type': 'object',
"properties": {
"name": {
"type": 'string'
}
},
"required": ['name']
})
end

pending 'returns a custom class type with options' do
prop = described_class.new(:name, custom_class, title: 'Custom Class', description: 'some description').as_json
expect(prop).to include_json({
'type': 'object',
"title": 'Custom Class',
"description": 'some description',
"properties": {
"name": {
"type": 'string'
}
},
"required": ['name']
})
end
end
end

Expand Down

0 comments on commit 938d2e8

Please sign in to comment.