Sha256: 02b92214b4225546aef7a54e31a9dd8dcac3084fe6c326f16684b74d139ff23a

Contents?: true

Size: 1012 Bytes

Versions: 3

Compression:

Stored size: 1012 Bytes

Contents

require './spec/spec_helper'

describe RestPack::Serializer::Factory do
  let(:factory) { RestPack::Serializer::Factory }

  it "creates by string" do
    factory.create("Song").should be_an_instance_of(MyApp::SongSerializer)
  end
  it "creates by lowercase string" do
    factory.create("song").should be_an_instance_of(MyApp::SongSerializer)
  end
  it "creates by lowercase plural string" do
    factory.create("songs").should be_an_instance_of(MyApp::SongSerializer)
  end
  it "creates by symbol" do
    factory.create(:song).should be_an_instance_of(MyApp::SongSerializer)
  end
  it "creates by class" do
    factory.create(MyApp::Song).should be_an_instance_of(MyApp::SongSerializer)
  end

  it "creates multiple with Array" do
    serializers = factory.create("Song", "artists", :album)
    serializers[0].should be_an_instance_of(MyApp::SongSerializer)
    serializers[1].should be_an_instance_of(MyApp::ArtistSerializer)
    serializers[2].should be_an_instance_of(MyApp::AlbumSerializer)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
restpack_serializer-0.4.5 spec/factory/factory_spec.rb
restpack_serializer-0.4.4 spec/factory/factory_spec.rb
restpack_serializer-0.4.3 spec/factory/factory_spec.rb