doc_topic_test.rb
1.13 KB
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
# encoding: UTF-8
require_relative "../test_helper"
class DocTopicTest < ActiveSupport::TestCase
should 'be a DocItem' do
assert_kind_of DocItem, DocTopic.new
end
should 'load topic data from file' do
doc = DocTopic.loadfile(Rails.root.join('test', 'fixtures', 'files', 'doctest.en.xhtml'))
assert_equal 'en', doc.language
assert_equal 'Documentation test', doc.title
assert_match(/Documentation test/, doc.text)
assert_match(/This is a test document/, doc.text)
end
should 'load translated topic from file' do
doc = DocTopic.loadfile(Rails.root.join('test', 'fixtures', 'files', 'doctest.pt.xhtml'))
assert_equal 'pt', doc.language
assert_equal 'Teste da documentação', doc.title
end
should 'raise DocTopic::NotFound when trying to load an unexisting topic' do
assert_raise DocItem::NotFound do
DocTopic.loadfile('/path/to/unexisting/file.en.xhtml')
end
end
should 'read order from HTML' do
assert_equal 1, DocTopic.order('<h1 class="order-1">Some topic</h1>')
end
should 'use 0 as order by default' do
assert_equal 0, DocTopic.order('<h1>Some topic</h1>')
end
end