spec/schematic/generator/restrictions/mixin_spec.rb in schematic-0.6.2 vs spec/schematic/generator/restrictions/mixin_spec.rb in schematic-0.7.0
- old
+ new
@@ -1,43 +1,44 @@
-require "spec_helper"
+require 'spec_helper'
describe "Schematic::Generator::Restrictions::Mixin" do
describe ".to_xsd" do
context "with a model with a mixed in restriction" do
before do
class MixedInRestriction < Schematic::Generator::Restrictions::Base
def generate(builder)
for_validator ActiveModel::BlockValidator do |validator|
- builder.xs(:enumeration, "value" => "cheese")
+ builder.xs(:enumeration, 'value' => 'cheese')
end
end
end
end
subject { sanitize_xml(TestModel.to_xsd) }
with_model :test_model do
table :id => false do |t|
- t.string "title"
+ t.string 'title'
end
model do
+ self.primary_key = :title
validates_each :title do |object, attr, value|
end
end
end
it "should validate against it's own XSD" do
- invalid_instance = TestModel.new(:title => "cake")
+ invalid_instance = TestModel.new(:title => 'cake')
xml = [invalid_instance].to_xml
- lambda {
+ expect {
validate_xml_against_xsd(xml, subject)
- }.should raise_error
- valid_instance = TestModel.new(:title => "cheese")
+ }.to raise_error
+ valid_instance = TestModel.new(:title => 'cheese')
xml = [valid_instance].to_xml
- lambda {
+ expect {
validate_xml_against_xsd(xml, subject)
- }.should_not raise_error
+ }.not_to raise_error
end
it "should mark that the field with the allowed values" do
xsd = generate_xsd_for_model(TestModel) do
<<-XML
@@ -51,15 +52,10 @@
</xs:complexType>
</xs:element>
XML
end
- subject.should == xsd
+ expect(subject).to eq(xsd)
end
end
end
end
-
-
-
-
-