blob: b1ad79958412ef0869944fa4a0899d59a2526f73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
require 'tc_helper'
class TestRelationships < Test::Unit::TestCase
def test_for
source_obj_1 = Object.new
source_obj_2 = Object.new
rel_1 = Axlsx::Relationship.new(source_obj_1, Axlsx::WORKSHEET_R, "bar")
rel_2 = Axlsx::Relationship.new(source_obj_2, Axlsx::WORKSHEET_R, "bar")
rels = Axlsx::Relationships.new
rels << rel_1
rels << rel_2
assert_equal rel_1, rels.for(source_obj_1)
assert_equal rel_2, rels.for(source_obj_2)
end
def test_valid_document
@rels = Axlsx::Relationships.new
schema = Nokogiri::XML::Schema(File.open(Axlsx::RELS_XSD))
doc = Nokogiri::XML(@rels.to_xml_string)
errors = []
schema.validate(doc).each do |error|
puts error.message
errors << error
end
@rels << Axlsx::Relationship.new(nil, Axlsx::WORKSHEET_R, "bar")
doc = Nokogiri::XML(@rels.to_xml_string)
errors = []
schema.validate(doc).each do |error|
puts error.message
errors << error
end
assert_empty(errors)
end
end
|