File: dl.rb

package info (click to toggle)
ruby-bluefeather 0.41-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 676 kB
  • ctags: 169
  • sloc: ruby: 4,195; makefile: 8
file content (182 lines) | stat: -rw-r--r-- 3,817 bytes parent folder | download | duplicates (5)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
require 'pathname'
require(Pathname.new(__FILE__).parent + 'lib/common.rb')


describe 'Definition List:' do
	before(:each) do
		@bf = BlueFeather::Parser.new
		@html = @bf.parse_text(@src)
		@doc = Nokogiri(@html)
	end
	
	describe 'Basic:' do
		describe 'most standard:'do
			before(:all) do
				@src = ("dt1\n:dd1\n\ndt2\n:dd2-\ndouble-line")
			end
			
			specify 'overview' do
				@doc.should have_elements(1, 'dl')
				@doc.should have_elements(2, 'dl dt')
				@doc.should have_elements(2, 'dl dd')
			end
			
			specify 'text' do
				@doc.search('dl dt')[0].inner_text.should == "dt1"
				@doc.search('dl dt')[1].inner_text.should == "dt2"
				@doc.search('dl dd')[0].inner_text.should == "dd1"
				@doc.search('dl dd')[1].inner_text.should == "dd2-\ndouble-line"
			end

		end
		
		describe 'double dt:'do
			before(:all) do
				@src = ("dt1\ndt2\n:dd")
			end
			
			specify 'overview' do
				@doc.should have_elements(1, 'dl')
				@doc.should have_elements(2, 'dl dt')
				@doc.should have_elements(1, 'dl dd')
			end
			
			specify 'text' do
				@doc.search('dl dt')[0].inner_text.should == 'dt1'
				@doc.search('dl dt')[1].inner_text.should == 'dt2'
				@doc.at('dl dd').inner_text.should == "dd"
			end
		end
		
		describe 'double dd:'do
			before(:all) do
				@src = ("dt\n:dd1\n:dd2")
			end
			
			specify 'overview' do
				@doc.should have_elements(1, 'dl')
				@doc.should have_elements(1, 'dl dt')
				@doc.should have_elements(2, 'dl dd')
			end
			
			specify 'text' do
				@doc.search('dl dd')[0].inner_text.should == "dd1"
				@doc.search('dl dd')[1].inner_text.should == "dd2"
				@doc.at('dl dt').inner_text.should == 'dt'
			end
		end


	end


	describe '> code-block > ol:' do
		before(:all) do
			@src = <<-SRC
title

:

		1. olitem-1
		2. olitem-2
		3. olitem-3
        
			SRC
		end
		
		specify 'overview' do
			@doc.should have_elements(1, 'dl dt')
			@doc.should have_elements(1, 'dl dd')
		end
		
		specify 'dt text' do
			@doc.at('dt').inner_text.should == 'title'
		end
		
		specify 'ol in code-block' do
			@doc.should have_element('dd pre code')
			
			code = @doc / 'dd pre code'
			code.inner_text.should =~ /\A1.+\n2.+\n3.+\n\z/
		end

	end
	
	describe '> code-block > ol(with paragraphs):' do
		before(:all) do
			@src = <<-SRC
title

:paragraph1

		1. olitem-1
		2. olitem-2
		3. olitem-3
		
	paragraph2

			SRC
		end
		
		specify 'overview' do
			@doc.should have_elements(1, 'dl dt')
			@doc.should have_elements(1, 'dl dd')
			@doc.should have_elements(2, 'dl dd p')
		end
		
		specify 'dt text' do
			@doc.at('dt').inner_text.should == 'title'
		end
		
		specify 'ol in code-block' do
			@doc.should have_element('dd pre code')
			
			code = @doc / 'dd pre code'
			code.inner_text.should =~ /\A1.+\n2.+\n3.+\n\z/
		end
		
		specify 'paragraphs' do
			paragraphs = @doc / 'dl dd p'
			paragraphs[0].inner_text.should == 'paragraph1'
			paragraphs[1].inner_text.should == 'paragraph2'
		end

	end
	

	describe 'blockquote > code-block > ol and paragraphs:' do
		before(:all) do
			@src = <<-SRC
>title
>
>:paragraph1
>
>         1. olitem-1
>         2. olitem-2
>         3. olitem-3
>
>     paragraph2

			SRC
		end
		
		specify 'overview' do
			@doc.should have_elements(1, 'blockquote dl dt')
			@doc.should have_elements(1, 'blockquote dl dd')
			@doc.should have_elements(2, 'blockquote dl dd p')
		end
		
		specify 'dt text' do
			@doc.at('blockquote dt').inner_text.should == 'title'
		end
		
		specify 'paragraphs' do
			paragraphs = @doc / 'blockquote dl dd p'
			paragraphs[0].inner_text.should == 'paragraph1'
			paragraphs[1].inner_text.should == 'paragraph2'
		end

	end


end