Sha256: 0c08c5b690775b625c5e646255fd0aef9353235404dcc6f1c9208a9942ef08bb

Contents?: true

Size: 794 Bytes

Versions: 33

Compression:

Stored size: 794 Bytes

Contents

require 'spec_helper'

describe RestPack::Serializer::Single do
  before(:each) do
    @album = FactoryGirl.create(:album_with_songs, song_count: 11)
    @song = @album.songs.first
  end

  let(:resource) { MyApp::SongSerializer.single(params, scope, context) }
  let(:params) { { id: @song.id } }
  let(:scope) { nil }
  let(:context) { { } }

  it "returns a resource by id" do
    resource[:id].should == @song.id.to_s
    resource[:title].should == @song.title
  end

  context "with context" do
    let(:context) { { reverse_title?: true } }

    it "returns reversed titles" do
      resource[:title].should == @song.title.reverse
    end
  end

  context "invalid id" do
    let(:params) { { id: @song.id + 100 } }

    it "returns nil" do
      resource.should == nil
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
restpack_serializer-0.6.7 spec/serializable/single_spec.rb
restpack_serializer-0.6.6 spec/serializable/single_spec.rb
restpack_serializer-0.6.5 spec/serializable/single_spec.rb
restpack_serializer-0.6.4 spec/serializable/single_spec.rb
restpack_serializer-0.6.3 spec/serializable/single_spec.rb
restpack_serializer-0.6.2 spec/serializable/single_spec.rb
restpack_serializer-0.6.1 spec/serializable/single_spec.rb
restpack_serializer-0.5.10 spec/serializable/single_spec.rb
restpack_serializer-0.5.9 spec/serializable/single_spec.rb
restpack_serializer-0.5.8 spec/serializable/single_spec.rb
restpack_serializer-0.5.7 spec/serializable/single_spec.rb
restpack_serializer-0.5.6 spec/serializable/single_spec.rb
restpack_serializer-0.5.5 spec/serializable/single_spec.rb
restpack_serializer-0.5.4 spec/serializable/single_spec.rb
restpack_serializer-0.5.3 spec/serializable/single_spec.rb
restpack_serializer-0.5.2 spec/serializable/single_spec.rb
restpack_serializer-0.5.1 spec/serializable/single_spec.rb
restpack_serializer-0.5.0 spec/serializable/single_spec.rb
restpack_serializer-0.4.28 spec/serializable/single_spec.rb
restpack_serializer-0.4.27 spec/serializable/single_spec.rb