Sha256: 8538bf186a8b75bfe995dd2048cf253aabae56fd0b890a646608cbf42e818288

Contents?: true

Size: 1.04 KB

Versions: 25

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe RestModel::Property do
  describe "#initialize" do
    context "serializer" do
      context "when custom is provided" do
        subject do
          options = {type: RestModel::Serialization::Boolean}
          RestModel::Property.new(:haz_bool?, options)
        end

        it "configures custom" do
          subject.serializer.should == RestModel::Serialization::Boolean
        end
      end

      context "when it isn't provided" do
        subject {RestModel::Property.new(:login)}

        it "uses String serializer" do
          subject.serializer.should == RestModel::Serialization::String
        end
      end
    end

    context "when values map is provided" do
      let(:values) {{paid: '01', unpaid: '02'}}

      subject do
        options = {values: values}
        RestModel::Property.new(:payment_status, options)
      end

      it "configures values" do
        subject.translation.should be_a(RestModel::Source::Translation)
        subject.translation.values.should == values
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rest_model-0.3.1 spec/unit/key/property_spec.rb
rest_model-0.3.0 spec/unit/key/property_spec.rb
rest_model-0.2.3 spec/unit/key/property_spec.rb
rest_model-0.2.1 spec/unit/key/property_spec.rb
rest_model-0.2.0 spec/unit/key/property_spec.rb
rest_model-0.1.24 spec/unit/key/property_spec.rb
rest_model-0.1.23 spec/unit/key/property_spec.rb
rest_model-0.1.22 spec/unit/key/property_spec.rb
rest_model-0.1.21 spec/unit/key/property_spec.rb
rest_model-0.1.20 spec/unit/key/property_spec.rb
rest_model-0.1.19 spec/unit/key/property_spec.rb
rest_model-0.1.18 spec/unit/key/property_spec.rb
rest_model-0.1.17 spec/unit/key/property_spec.rb
rest_model-0.1.16 spec/unit/key/property_spec.rb
rest_model-0.1.15 spec/unit/key/property_spec.rb
rest_model-0.1.14 spec/unit/key/property_spec.rb
rest_model-0.1.13 spec/unit/key/property_spec.rb
rest_model-0.1.12 spec/unit/key/property_spec.rb
rest_model-0.1.11 spec/unit/key/property_spec.rb
rest_model-0.1.10 spec/unit/key/property_spec.rb