Sha256: 50f7c1d2ef41a31d21159e88ba8c3ebcb9108abd5c6fd4ba70e14333325ee072
Contents?: true
Size: 1.45 KB
Versions: 29
Compression:
Stored size: 1.45 KB
Contents
require "spec_helper" describe Schematic::Generator::Restrictions::Numericality do describe ".to_xsd" do context "with a model with numericality validations" do subject { sanitize_xml(TestModel.to_xsd) } with_model :test_model do table :id => false do |t| t.string "some_field" end model do validates :some_field, :numericality => true end end it "should validate against it's own XSD" do invalid_instance = TestModel.new(:some_field => "1a2") xml = [invalid_instance].to_xml lambda { validate_xml_against_xsd(xml, subject) }.should raise_error valid_instance = TestModel.new(:some_field => "123") xml = [valid_instance].to_xml lambda { validate_xml_against_xsd(xml, subject) }.should_not raise_error end it "should mark that the field with the allowed values" do xsd = generate_xsd_for_model(TestModel) do <<-XML <xs:element name="some-field" minOccurs="0" maxOccurs="1"> <xs:complexType> <xs:simpleContent> <xs:restriction base="String"> <xs:pattern value="\\d+"/> </xs:restriction> </xs:simpleContent> </xs:complexType> </xs:element> XML end subject.should == xsd end end end end
Version data entries
29 entries across 29 versions & 1 rubygems