-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathshared_string_spec.rb
35 lines (31 loc) · 1.34 KB
/
shared_string_spec.rb
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
require './spec/spec_helper'
describe 'shared strings' do
it 'parses rich text strings correctly' do
shared_strings_xml_file = File.open('spec/fixtures/sst.xml')
doc = Nokogiri::XML(shared_strings_xml_file)
dictionary = Creek::SharedStrings.parse_shared_string_from_document(doc)
expect(dictionary.keys.size).to eq(7)
expect(dictionary[0]).to eq('Cell A1')
expect(dictionary[1]).to eq('Cell B1')
expect(dictionary[2]).to eq('My Cell')
expect(dictionary[3]).to eq('Cell A2')
expect(dictionary[4]).to eq('Cell B2')
expect(dictionary[5]).to eq("Cell with\rescaped\rcharacters")
expect(dictionary[6]).to eq('吉田兼好')
end
context 'when the nodes are namespaced' do
it 'parses the dictionary correctly' do
shared_strings_xml_file = File.open('spec/fixtures/sst_namespaced.xml')
doc = Nokogiri::XML(shared_strings_xml_file)
dictionary = Creek::SharedStrings.parse_shared_string_from_document(doc)
expect(dictionary.keys.size).to eq(7)
expect(dictionary[0]).to eq('Cell A1')
expect(dictionary[1]).to eq('Cell B1')
expect(dictionary[2]).to eq('My Cell')
expect(dictionary[3]).to eq('Cell A2')
expect(dictionary[4]).to eq('Cell B2')
expect(dictionary[5]).to eq("Cell with\rescaped\rcharacters")
expect(dictionary[6]).to eq('吉田兼好')
end
end
end