File: numbering.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 (58 lines) | stat: -rw-r--r-- 1,139 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
require 'pathname'
require(Pathname.new(__FILE__).parent + 'lib/common.rb')


describe 'Numbering:' do
	before(:each) do
		@src = <<MARKDOWN
Numbering: #{@numbering}
Numbering-Start-Level: #{@start_level}

# h1
## h2a
## h2b
### h3a
### h3b
## h2c
MARKDOWN

		@html = BlueFeather.parse_document(@src)
		@doc = Nokogiri(@html)
	end
	
	
	describe "yes:" do
		before(:all) do
			@numbering, @start_level = 'yes  ', ''
		end

		specify "numbering" do
			@doc.at('h1').inner_text.should == 'h1'
			
			elems = @doc.search('h2')
			elems.map{|x| x.inner_text}.should == ['1. h2a', '2. h2b', '3. h2c']
			
			elems = @doc.search('h3')
			elems.map{|x| x.inner_text}.should == ['2.1. h3a', '2.2. h3b']
		end

	end
	
	describe "yes (start=3):" do
		before(:all) do
			@numbering, @start_level = 'yes  ', '3 '
		end

		specify "numbering" do
			@doc.at('h1').inner_text.should == 'h1'
			
			elems = @doc.search('h2')
			elems.map{|x| x.inner_text}.should == ['h2a', 'h2b', 'h2c']
			
			elems = @doc.search('h3')
			elems.map{|x| x.inner_text}.should == ['1. h3a', '2. h3b']
		end

	end

end