Sha256: a60bd30ea213efc6fa340191c73731dcb94c84e2c28a87934e59cc1ca090b579
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
require 'test/unit' require 'xcdm/schema' require 'rexml/document' require 'active_support/all' module XCDM class SchemaTest < Test::Unit::TestCase def test_initialize s = Schema.new("0.0.1", "4.6") assert_equal "0.0.1", s.version assert_equal "4.6", s.xcode_version end def test_entity s = Schema.new("0.0.1", "4.6") entity = nil s.entity("MyType") { entity = self; nil } assert entity.is_a?(Entity), "Block should be executed in context of the new entity" assert_equal [entity], s.entities end def test_loader fixture = File.join(File.dirname(__FILE__), 'fixtures', '001_baseline.rb') loader = Schema::Loader.new("4.6") schema = loader.load_file(fixture) assert_not_nil schema assert_equal '0.0.1', schema.version assert_equal schema, loader.schemas.first assert_equal ['Article', 'Author'], schema.entities.map(&:name) end def test_to_xml in_fixture = File.join(File.dirname(__FILE__), 'fixtures', '001_baseline.rb') loader = Schema::Loader.new("4.6") schema = loader.load_file(in_fixture) out_fixture = File.join(File.dirname(__FILE__), 'fixtures', 'Article.xcdatamodeld', 'Article.xcdatamodel', 'contents') inlines = REXML::Document.new(File.read(out_fixture)).to_s.split("\n").map(&:strip) outlines = REXML::Document.new(schema.to_xml).to_s.split("\n").map(&:strip) inlines.each_with_index do |line, i| assert_equal line, outlines[i] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ruby-xcdm-0.0.8 | test/schema_test.rb |
ruby-xcdm-0.0.7 | test/schema_test.rb |
ruby-xcdm-0.0.6 | test/schema_test.rb |
ruby-xcdm-0.0.5 | test/schema_test.rb |
ruby-xcdm-0.0.4 | test/schema_test.rb |