Sha256: 34bc30a997122fa9e1c85e05b0544d2d0401de124054a6eb8078010783af4654

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

# instance methods
describe Ardm::Property do
  describe ".find_class" do
    [ :Serial, :Text ].each do |type|
      describe "with #{type}" do
        subject { Ardm::Property.find_class(type) }

        it { expect(subject).to be(Ardm::Property.const_get(type)) }
      end
    end
  end

  describe ".determine_class" do
    [ Integer, String, Float, Class, String, Time, DateTime, Date ].each do |type|
      describe "with #{type}" do
        subject { Ardm::Property.determine_class(type) }

        it { expect(subject).to be(Ardm::Property.const_get(type.name)) }
      end
    end

    describe "with property subclasses" do
      before do
        Object.send(:remove_const, :CustomProps) if Object.const_defined?(:CustomProps)

        module ::CustomProps
          module Property
            class Hash   < Ardm::Property::Object; end
            class Other  < Ardm::Property::Object; end
            class Serial < Ardm::Property::Object; end
          end
        end
      end

      describe "with ::Foo::Property::Hash" do
        subject { Ardm::Property.determine_class(Hash) }

        it { expect(subject).to be(::CustomProps::Property::Hash) }
      end

      describe "with ::Foo::Property::Other" do
        subject { Ardm::Property.determine_class(::CustomProps::Property::Other) }

        it { expect(subject).to be(::CustomProps::Property::Other) }
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ardm-0.4.0.ar427 spec/semipublic/property_spec.rb
ardm-0.4.0 spec/semipublic/property_spec.rb
ardm-0.3.2 spec/semipublic/property_spec.rb
ardm-0.3.1 spec/semipublic/property_spec.rb
ardm-0.3.0 spec/semipublic/property_spec.rb
ardm-0.2.7 spec/semipublic/property_spec.rb
ardm-0.2.6 spec/semipublic/property_spec.rb
ardm-0.2.5 spec/semipublic/property_spec.rb
ardm-0.2.4 spec/semipublic/property_spec.rb
ardm-0.2.3 spec/semipublic/property_spec.rb
ardm-0.2.2 spec/semipublic/property_spec.rb
ardm-0.2.1 spec/semipublic/property_spec.rb
ardm-0.2.0 spec/semipublic/property_spec.rb
ardm-0.1.0 spec/semipublic/property_spec.rb