Sha256: b5a35cc7240f6546ae79b2a3db1156f2bad9e7825e504651182484fb5eeb23ef

Contents?: true

Size: 1.07 KB

Versions: 29

Compression:

Stored size: 1.07 KB

Contents

require "spec_helper"

describe Schematic::Serializers::Xsd do

  describe ".minimum_occurrences_for_column" do
    subject { Schematic::Generator::Column.new(SomeModel, column).minimum_occurrences_for_column }
    let(:column) { SomeModel.columns.first }

    context "given a column with no validations" do
      with_model :some_model do
        table :id => false do |t|
          t.string "title"
        end
        model {}
      end

      it { should == "0" }
    end

    context "given a column with presence of but allow blank" do
      with_model :some_model do
        table :id => false do |t|
          t.string "title"
        end
        model do
          validates :title, :presence => true, :allow_blank => true
        end
      end

      it { should == "0" }
    end

    context "given a column with presence of and no allow blank" do
      with_model :some_model do
        table :id => false do |t|
          t.string "title"
        end
        model do
          validates :title, :presence => true
        end
      end

      it { should == "1" }
    end
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
schematic-0.5.4 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.5.3 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.5.2 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.5.1 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.5.0 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.4.4 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.4.3 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.4.2 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.4.1 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.4.0 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.8 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.7 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.6 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.5 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.4 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.3 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.2 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.1 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.3.0 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb
schematic-0.2.3 spec/schematic/serializers/xsd_xsd_minimum_occurrences_for_spec.rb