schematic 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -109,7 +109,7 @@ module Schematic
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def xsd_type_name
|
112
|
-
self.name
|
112
|
+
self.name.demodulize
|
113
113
|
end
|
114
114
|
|
115
115
|
def xsd_type_collection_name
|
@@ -117,7 +117,7 @@ module Schematic
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def xsd_element_name
|
120
|
-
|
120
|
+
xsd_type_name.underscore.dasherize
|
121
121
|
end
|
122
122
|
|
123
123
|
def xsd_element_collection_name
|
data/lib/schematic/version.rb
CHANGED
@@ -39,31 +39,67 @@ describe Schematic::Serializers::Xsd do
|
|
39
39
|
describe ".to_xsd" do
|
40
40
|
|
41
41
|
context "XSD validation" do
|
42
|
-
|
42
|
+
context "when the model is not namespaced" do
|
43
|
+
subject { SomeModel.to_xsd }
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
with_model :some_model do
|
46
|
+
table do |t|
|
47
|
+
t.string "some_string"
|
48
|
+
t.float "some_float"
|
49
|
+
t.datetime "some_datetime"
|
50
|
+
t.date "some_date"
|
51
|
+
t.boolean "some_boolean"
|
52
|
+
end
|
53
|
+
|
54
|
+
model do
|
55
|
+
validates :some_string, :presence => true
|
56
|
+
validates :some_date, :presence => true, :allow_blank => true
|
57
|
+
validates :some_datetime, :presence => true, :allow_blank => false
|
58
|
+
end
|
52
59
|
|
53
|
-
model do
|
54
|
-
validates :some_string, :presence => true
|
55
|
-
validates :some_date, :presence => true, :allow_blank => true
|
56
|
-
validates :some_datetime, :presence => true, :allow_blank => false
|
57
60
|
end
|
61
|
+
it "should generate a valid XSD" do
|
62
|
+
xsd_schema_file = File.join(File.dirname(__FILE__), "xsd", "XMLSchema.xsd")
|
63
|
+
meta_xsd = Nokogiri::XML::Schema(File.open(xsd_schema_file))
|
58
64
|
|
65
|
+
doc = Nokogiri::XML.parse(subject)
|
66
|
+
meta_xsd.validate(doc).each do |error|
|
67
|
+
error.message.should be_nil
|
68
|
+
end
|
69
|
+
end
|
59
70
|
end
|
60
|
-
it "should generate a valid XSD" do
|
61
|
-
xsd_schema_file = File.join(File.dirname(__FILE__), "xsd", "XMLSchema.xsd")
|
62
|
-
meta_xsd = Nokogiri::XML::Schema(File.open(xsd_schema_file))
|
63
71
|
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
context "when the model is namespaced" do
|
73
|
+
before do
|
74
|
+
module Namespace; end
|
75
|
+
end
|
76
|
+
|
77
|
+
subject { Namespace::SomeModel.to_xsd }
|
78
|
+
|
79
|
+
with_model :some_model do
|
80
|
+
table do |t|
|
81
|
+
t.string "some_string"
|
82
|
+
end
|
83
|
+
|
84
|
+
model do
|
85
|
+
validates :some_string, :presence => true
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
before do
|
91
|
+
class Namespace::SomeModel < SomeModel
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should generate a valid XSD" do
|
96
|
+
xsd_schema_file = File.join(File.dirname(__FILE__), "xsd", "XMLSchema.xsd")
|
97
|
+
meta_xsd = Nokogiri::XML::Schema(File.open(xsd_schema_file))
|
98
|
+
|
99
|
+
doc = Nokogiri::XML.parse(subject)
|
100
|
+
meta_xsd.validate(doc).each do |error|
|
101
|
+
error.message.should be_nil
|
102
|
+
end
|
67
103
|
end
|
68
104
|
end
|
69
105
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: schematic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Case Commons, LLC
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-05 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|