spec/csl/schema_spec.rb in csl-1.0.0.pre1 vs spec/csl/schema_spec.rb in csl-1.0.0.pre2
- old
+ new
@@ -1,10 +1,14 @@
require 'spec_helper'
module CSL
describe 'Schema' do
+ it 'cannot be instantiated' do
+ Schema.should_not respond_to(:new)
+ end
+
describe '.version' do
it 'returns a version string' do
Schema.version.should match(/^\d+\.\d+\.\d+/)
end
@@ -52,19 +56,48 @@
end
end
describe '.categories' do
it 'given a field name returns the corresponding type' do
- Schema.categories[:author].should == :names
- Schema.categories[:issued].should == :date
- Schema.categories[:abstract].should == :text
- Schema.categories[:issue].should == :number
+ Schema.categories.values_at(:author, :issued, :abstract, :issue).should ==
+ [:names, :date, :text, :number]
end
it 'accepts either string or symbol input' do
Schema.categories.should have_key(:author)
Schema.categories['author'].should equal Schema.categories[:author]
end
+ end
+
+ describe '.validate' do
+ it 'accepts and validates a locale instance' do
+ Schema.validate(Locale.load('en-US')).should == []
+ end
+
+ it 'accepts and validates a locale file path' do
+ Schema.validate(File.join(Locale.root, 'locales-en-US.xml')).should == []
+ end
+
+ it 'accepts and validates a locale file' do
+ Schema.validate(File.open(File.join(Locale.root, 'locales-en-US.xml'))).should == []
+ end
+
+ it 'accepts and validates a locale wildcard path' do
+ Schema.validate(File.join(Locale.root, 'locales-en-*.xml')).should == []
+ end
+
+ it 'accepts and validates a style file path' do
+ Schema.validate(File.join(Style.root, 'apa.csl')).should == []
+ end
+
+ it 'accepts and validates the xml contents of a style instance' do
+ Schema.validate(Style.load(:apa).pretty_print).should == []
+ end
+
+ it 'accepts and validates a style instance' do
+ Schema.validate(Style.load(:apa)).should == []
+ end
+
end
end
end
\ No newline at end of file