spec/result_spec.rb in restpack_serializer-0.6.7 vs spec/result_spec.rb in restpack_serializer-0.6.8

- old
+ new

@@ -1,22 +1,23 @@ require 'spec_helper' describe RestPack::Serializer::Result do context 'a new instance' do it 'has defaults' do - subject.resources.should == {} - subject.meta.should == {} - subject.links.should == {} + expect(subject.resources).to eq({}) + expect(subject.meta).to eq({}) + expect(subject.links).to eq({}) end end context 'when serializing' do let(:result) { subject.serialize } + context 'in jsonapi.org format' do context 'an empty result' do it 'returns an empty result' do - result.should == {} + expect(result).to eq({}) end end context 'a simple list of resources' do before do @@ -24,13 +25,13 @@ subject.meta[:albums] = { count: 2 } subject.links['albums.songs'] = { href: 'songs.json', type: 'songs' } end it 'returns correct jsonapi.org format' do - result[:albums].should == subject.resources[:albums] - result[:meta].should == subject.meta - result[:links].should == subject.links + expect(result[:albums]).to eq(subject.resources[:albums]) + expect(result[:meta]).to eq(subject.meta) + expect(result[:links]).to eq(subject.links) end end context 'a list with side-loaded resources' do before do @@ -41,29 +42,29 @@ subject.links['albums.songs'] = { type: 'songs', href: '/api/v1/songs?album_id={albums.id}' } subject.links['songs.album'] = { type: 'albums', href: '/api/v1/albums/{songs.album}' } end it 'returns correct jsonapi.org format, including injected has_many links' do - result[:albums].should == [{ id: '1', name: 'AMOK', links: { songs: ['91'] } }] - result[:links].should == subject.links - result[:linked][:songs].should == subject.resources[:songs] + expect(result[:albums]).to eq([{ id: '1', name: 'AMOK', links: { songs: ['91'] } }]) + expect(result[:links]).to eq(subject.links) + expect(result[:linked][:songs]).to eq(subject.resources[:songs]) end it 'includes resources in correct order' do - result.keys[0].should == :albums - result.keys[1].should == :linked - result.keys[2].should == :links - result.keys[3].should == :meta + expect(result.keys[0]).to eq(:albums) + expect(result.keys[1]).to eq(:linked) + expect(result.keys[2]).to eq(:links) + expect(result.keys[3]).to eq(:meta) end context 'with multiple calls to serialize' do let(:result) do subject.serialize subject.serialize end it 'does not create duplicate has_many links' do - result[:albums].first[:links][:songs].count.should == 1 + expect(result[:albums].first[:links][:songs].count).to eq(1) end end end end end