Sha256: d4495911c3c311b3a2afafec62efcd00b1013f8a3777a567d09d14f5268466cf

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8
#
# Copyright 2011 Brennan Frydl (http://bfrydl.com/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'spec_helper'

describe Settis::Serializer do
  before :all do
    @serializer = Class.new(Settis::Serializer)
  end

  describe '#inherited' do
    it 'adds the subclass to the list of serializers' do
      Settis::Serializer.class_eval { @serializers }.should include @serializer
    end
  end

  describe '#for' do
    it 'returns the appropriate serializer' do
      Settis::Serializer.for(:string).should == Settis::StringSerializer
      Settis::Serializer.for(Fixnum).should == Settis::IntegerSerializer

      Settis::Serializer.for(:testing).should be_nil
      stub(@serializer).serializes?(:testing) { true }
      Settis::Serializer.for(:testing).should == @serializer
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
settis-0.2.0 spec/settis/serializer_spec.rb