schematic 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/schematic/version.rb
CHANGED
@@ -51,10 +51,12 @@ describe Schematic::Generator::Restrictions::Pattern do
|
|
51
51
|
with_model :pattern_model do
|
52
52
|
table :id => false do |t|
|
53
53
|
t.string "email"
|
54
|
+
t.string "money"
|
54
55
|
end
|
55
56
|
|
56
57
|
model do
|
57
58
|
validates :email, :format => { :with => /\A([\w\.%\+\-`']+)@([\w\-]+\.)+([\w]{2,})\Z/ }
|
59
|
+
validates :money, :format => { :with => /\$?[,0-9]+(?:\.\d+)?/ }
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
@@ -64,7 +66,12 @@ describe Schematic::Generator::Restrictions::Pattern do
|
|
64
66
|
lambda {
|
65
67
|
validate_xml_against_xsd(xml, subject)
|
66
68
|
}.should raise_error
|
67
|
-
|
69
|
+
invalid_instance = PatternModel.new(:money => "whatever")
|
70
|
+
xml = [invalid_instance].to_xml
|
71
|
+
lambda {
|
72
|
+
validate_xml_against_xsd(xml, subject)
|
73
|
+
}.should raise_error
|
74
|
+
valid_instance = PatternModel.new(:email => "foo@bar.com", :money => "$99.95")
|
68
75
|
xml = [valid_instance].to_xml
|
69
76
|
lambda {
|
70
77
|
validate_xml_against_xsd(xml, subject)
|