Sha256: c6b68cb5d5b2e6349e93216690b59da99a03523520029ff97e6be085672e9bec

Contents?: true

Size: 1.59 KB

Versions: 13

Compression:

Stored size: 1.59 KB

Contents

require "spec_helper"

describe Schematic::Serializers::Xsd do
  with_model :empty_model do
  end
  before do
    class EmptyClass
      include ActiveModel::Serializers::Xml
    end
  end

  describe ".extend" do
    context "when the model inherits ActiveRecord::Base" do
      subject { EmptyModel }

      it "should allow the model to be extended" do
        lambda {
          subject.class_eval do
            extend Schematic::Serializers::Xsd
          end
        }.should_not raise_error
      end
    end

    context "when the class has ActiveModel::Serializers::Xml as an ancestor" do
      subject { EmptyClass }

      it "should raise an exception" do
        lambda {
          subject.class_eval do
            extend Schematic::Serializers::Xsd
          end
        }.should raise_error(Schematic::ClassMissingAttributes)
      end

      context "and it implements #attributes" do
        before do
          class EmptyClass
            def attributes
              {}
            end
          end
        end
        it "should allow the model to be extended" do
          lambda {
            subject.class_eval do
              extend Schematic::Serializers::Xsd
            end
          }.should_not raise_error
        end
      end
    end

    context "when the class does not have ActiveModel::Serializers::Xml as an ancestor" do
      subject { Object }

      it "should raise an exception" do
        lambda {
          subject.class_eval do
          extend Schematic::Serializers::Xsd
          end
        }.should raise_error(Schematic::ClassMissingXmlSerializer)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
schematic-0.6.2 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.6.1 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.6.0 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.9 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.8 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.7 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.6 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.5 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.4 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.3 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.2 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.1 spec/schematic/serializers/xsd_extend_spec.rb
schematic-0.5.0 spec/schematic/serializers/xsd_extend_spec.rb