osem-fcy/spec/serializers/speaker_serializer_spec.rb

38 lines
1,000 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-04-03 00:57:43 +05:30
require 'spec_helper'
describe SpeakerSerializer, type: :serializer do
let(:speaker) { create(:user, name: 'John Doe', affiliation: 'JohnDoesInc', biography: nil) }
let(:serializer) { SpeakerSerializer.new(speaker) }
context 'speaker does not have biography' do
it 'sets name and affiliation' do
expected_json = {
speaker: {
2018-11-13 18:01:49 -08:00
name: 'John Doe',
2016-04-03 00:57:43 +05:30
affiliation: 'JohnDoesInc',
2018-11-13 18:01:49 -08:00
biography: nil
2016-04-03 00:57:43 +05:30
}
}.to_json
expect(serializer.to_json).to eq expected_json
end
end
context 'speaker has biography' do
before{ speaker.update_attributes(biography: 'Doest of all Jon Does') }
it 'sets name, affiliation and biography' do
expected_json = {
speaker: {
2018-11-13 18:01:49 -08:00
name: 'John Doe',
2016-04-03 00:57:43 +05:30
affiliation: 'JohnDoesInc',
2018-11-13 18:01:49 -08:00
biography: 'Doest of all Jon Does'
2016-04-03 00:57:43 +05:30
}
}.to_json
expect(serializer.to_json).to eq expected_json
end
end
end