From 4256cdc06b6724e2540ea49b6481630c46e63380 Mon Sep 17 00:00:00 2001 From: James Mason Date: Sat, 29 Sep 2018 16:13:38 -0700 Subject: [PATCH] Adapt serializer specs to the new format --- spec/serializers/event_serializer_spec.rb | 44 +++-- spec/serializers/room_serializer_spec.rb | 8 +- spec/serializers/speaker_serializer_spec.rb | 16 +- spec/serializers/track_serializer_spec.rb | 8 +- spec/support/schemas/conference.json | 184 ++++++++++---------- 5 files changed, 122 insertions(+), 138 deletions(-) diff --git a/spec/serializers/event_serializer_spec.rb b/spec/serializers/event_serializer_spec.rb index 04ebd72b..2b678319 100644 --- a/spec/serializers/event_serializer_spec.rb +++ b/spec/serializers/event_serializer_spec.rb @@ -8,18 +8,16 @@ describe EventSerializer, type: :serializer do context 'event does not have date, room and tracks assigned' do it 'sets guid, title, length, abstract and type' do expected_json = { - event: { - guid: event.guid, - title: 'Some Talk', - length: 30, - scheduled_date: '', - language: nil, - abstract: 'Lorem ipsum dolor sit amet', - speaker_ids: event.speaker_ids, - type: 'Example Event Type', - room: nil, - track: nil - } + guid: event.guid, + title: 'Some Talk', + length: 30, + scheduled_date: '', + language: nil, + abstract: 'Lorem ipsum dolor sit amet', + speaker_ids: event.speaker_ids, + type: 'Example Event Type', + room: nil, + track: nil }.to_json expect(serializer.to_json).to eq expected_json @@ -40,18 +38,16 @@ describe EventSerializer, type: :serializer do it 'sets guid, title, length, abstract, type, date, language, speakers, room and track' do expected_json = { - event: { - guid: event.guid, - title: 'Some Talk', - length: 30, - scheduled_date: ' 2014-03-04T09:00:00+0000 ', - language: 'English', - abstract: 'Lorem ipsum dolor sit amet', - speaker_ids: [speaker.id], - type: 'Example Event Type', - room: room.guid, - track: track.guid - } + guid: event.guid, + title: 'Some Talk', + length: 30, + scheduled_date: ' 2014-03-04T09:00:00+0000 ', + language: 'English', + abstract: 'Lorem ipsum dolor sit amet', + speaker_ids: [speaker.id], + type: 'Example Event Type', + room: room.guid, + track: track.guid }.to_json expect(serializer.to_json).to eq expected_json diff --git a/spec/serializers/room_serializer_spec.rb b/spec/serializers/room_serializer_spec.rb index 466f7b88..bfb3ed86 100644 --- a/spec/serializers/room_serializer_spec.rb +++ b/spec/serializers/room_serializer_spec.rb @@ -7,11 +7,9 @@ describe RoomSerializer, type: :serializer do it 'set guid, name and description' do expected_json = { - room: { - guid: room.guid, - name: room.name, - description: '' - } + guid: room.guid, + name: room.name, + description: '' }.to_json expect(serializer.to_json).to eq expected_json diff --git a/spec/serializers/speaker_serializer_spec.rb b/spec/serializers/speaker_serializer_spec.rb index f26ba741..b3a1a869 100644 --- a/spec/serializers/speaker_serializer_spec.rb +++ b/spec/serializers/speaker_serializer_spec.rb @@ -8,11 +8,9 @@ describe SpeakerSerializer, type: :serializer do context 'speaker does not have biography' do it 'sets name and affiliation' do expected_json = { - speaker: { - name: 'John Doe', - affiliation: 'JohnDoesInc', - biography: nil - } + name: 'John Doe', + affiliation: 'JohnDoesInc', + biography: nil }.to_json expect(serializer.to_json).to eq expected_json @@ -24,11 +22,9 @@ describe SpeakerSerializer, type: :serializer do it 'sets name, affiliation and biography' do expected_json = { - speaker: { - name: 'John Doe', - affiliation: 'JohnDoesInc', - biography: 'Doest of all Jon Does' - } + name: 'John Doe', + affiliation: 'JohnDoesInc', + biography: 'Doest of all Jon Does' }.to_json expect(serializer.to_json).to eq expected_json diff --git a/spec/serializers/track_serializer_spec.rb b/spec/serializers/track_serializer_spec.rb index f367a19a..95c97056 100644 --- a/spec/serializers/track_serializer_spec.rb +++ b/spec/serializers/track_serializer_spec.rb @@ -8,11 +8,9 @@ describe TrackSerializer, type: :serializer do it 'sets guild, name, color' do expected_json = { - track: { - guid: track.guid, - name: track.name, - color: track.color - } + guid: track.guid, + name: track.name, + color: track.color }.to_json expect(serializer.to_json).to eq expected_json diff --git a/spec/support/schemas/conference.json b/spec/support/schemas/conference.json index 3117d98f..26e2c907 100644 --- a/spec/support/schemas/conference.json +++ b/spec/support/schemas/conference.json @@ -1,100 +1,96 @@ { - "type": "object", - "required": ["conference"], - "properties": { - "conference" : { - "type" : "object", - "required" : [ - "short_title", - "title", - "description", - "start_date", - "end_date", - "picture_url", - "difficulty_levels", - "event_types", - "rooms", - "tracks", - "date_range", - "revision" - ], - "properties" : { - "short_title": { - "type": "string" - }, - "title": { - "type": "string" - }, - "description": { - "type": "string" - }, - "start_date": { - "type": "string", "format": "date" - }, - "end_date": { - "type": "string", "format": "date" - }, - "picture_url": { - "anyOf": [ - { "type": "string" }, - { "type": "null" } - ] - }, - "difficulty_levels": { - "type": "array", - "items": { - "type": "object", - "required": ["id", "title", "description"], - "properties": { - "id": { "type": "integer" }, - "title": { "type": "string" }, - "description": { "type": "string" } - } + "conference" : { + "type" : "object", + "required" : [ + "short_title", + "title", + "description", + "start_date", + "end_date", + "picture_url", + "difficulty_levels", + "event_types", + "rooms", + "tracks", + "date_range", + "revision" + ], + "properties" : { + "short_title": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "start_date": { + "type": "string", "format": "date" + }, + "end_date": { + "type": "string", "format": "date" + }, + "picture_url": { + "anyOf": [ + { "type": "string" }, + { "type": "null" } + ] + }, + "difficulty_levels": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "title", "description"], + "properties": { + "id": { "type": "integer" }, + "title": { "type": "string" }, + "description": { "type": "string" } } - }, - "event_types": { - "type": "array", - "items": { - "type": "object", - "required": ["id", "title", "description", "length"], - "properties": { - "id": { "type": "integer" }, - "title": { "type": "string" }, - "description": { "type": "string" }, - "length": { "type": "integer" } - } - } - }, - "rooms": { - "type": "array", - "items": { - "type": "object", - "required": ["id", "size", "events"], - "properties": { - "id": { "type": "integer" }, - "size": { "type": "integer" }, - "events": { "type": "array" } - } - } - }, - "tracks": { - "type": "array", - "items": { - "type": "object", - "required": ["id", "name", "description"], - "properties": { - "id": { "type": "integer" }, - "name": { "type": "string" }, - "description": { "type": "string" } - } - } - }, - "date_range": { - "type": "string" - }, - "revision": { - "type": "integer" } + }, + "event_types": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "title", "description", "length"], + "properties": { + "id": { "type": "integer" }, + "title": { "type": "string" }, + "description": { "type": "string" }, + "length": { "type": "integer" } + } + } + }, + "rooms": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "size", "events"], + "properties": { + "id": { "type": "integer" }, + "size": { "type": "integer" }, + "events": { "type": "array" } + } + } + }, + "tracks": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "name", "description"], + "properties": { + "id": { "type": "integer" }, + "name": { "type": "string" }, + "description": { "type": "string" } + } + } + }, + "date_range": { + "type": "string" + }, + "revision": { + "type": "integer" } } }