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
|
require 'pathname'
require(Pathname.new(__FILE__).parent + 'lib/common.rb')
describe 'Simple Table:' do
before(:each) do
@bf = BlueFeather::Parser.new
@html = @bf.parse_text(@src)
@doc = Nokogiri(@html)
end
shared_context 'standard table' do
it "table overview" do
@doc.should have_elements(1, 'table')
end
it "size 3x3" do
@doc.should have_elements(3, 'tr')
@doc.should have_elements(1, 'thead tr')
@doc.should have_elements(2, 'tbody tr')
@doc.should have_elements(3, 'thead tr th')
@doc.should have_elements(6, 'tbody tr td')
end
it "alignment" do
@doc.search('tr').each do |tr|
cells = tr.search('th, td')
cells[0]['style'].should be_nil
cells[1]['style'].should == 'text-align: right'
cells[2]['style'].should == 'text-align: center'
end
end
it "purity" do
@doc.should_not have_element('p table')
end
end
describe 'no-doubleline' do
include_context 'standard table'
before(:all) do
@src = "|h1|h2|h3\n|-|-:|:-:\n|d11|d21|d31\n|d12|d22|d32"
end
end
describe 'doubleline: ' do
include_context 'standard table'
before(:all) do
@src = "|h1|h2|h3|\n|-|-:|:-:|\n|d11|d21|d31|\n|d12|d22|d32|"
end
end
describe 'inner space:' do
include_context 'standard table'
before(:all) do
@src = "| h1 | h2 | h3 \n| - | -: | :-: \n| d11 | d21 | d31\n| d12 | d22 | d32"
end
end
describe 'left space:' do
include_context 'standard table'
before(:all) do
@src = " | h1 | h2 | h3 \n | - | -: | :-: \n | d11 | d21 | d31\n | d12 | d22 | d32"
end
end
describe 'in definition list:' do
include_context 'standard table'
before(:all) do
@src = <<MARKDOWN
Apple
: Apple content
| h1 | h2 | h3
| - | -: | :-:
| d11 | d21 | d31
| d12 | d22 | d32
MARKDOWN
end
end
end
|