# -*- coding: utf-8; -*- require 'spec_helper' require 'tdiary' require 'tdiary/style/wiki_style' describe TDiary::WikiDiary do before do @diary = TDiary::WikiDiary.new(Time.at( 1041346800 ), "TITLE", "") end describe '#append' do before do @source = <<-'EOF' ! subTitle honbun !! subTitleH4 honbun EOF @diary.append(@source) end context 'HTML' do before do @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

subTitleH4

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

subTitleH4

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%> EOF end it { @diary.to_html({}, :CHTML).should eq @html } end context 'to_src' do it { @diary.to_src.should eq @source } end end describe '#replace' do before do source = <<-'EOF' ! subTitle honbun !! subTitleH4 honbun EOF @diary.append(source) replaced = <<-'EOF' ! replaceTitle replace !! replaceTitleH4 replace EOF @diary.replace(Time.at( 1041346800 ), "TITLE", replaced) @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "replaceTitle" ) %>

replace

replaceTitleH4

replace

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end describe '#add_section' do before do source = <<-'EOF' ! subTitle honbun !! subTitleH4 honbun EOF @diary.append(source) @diary.add_section('subTitle2', 'honbun') @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

subTitleH4

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%>
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle2" ) %>

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end describe '#delete_section' do before do source = <<-'EOF' ! subTitle honbun ! subTitle2 honbun EOF @diary.append(source) @diary.delete_section(1) @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle2" ) %>

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end describe 'test_wiki_style2' do before do source = <<-'EOF' subTitle honbun honbun EOF @diary.append(source) end context 'HTML' do before do @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%> EOF end it { @diary.to_html({}, :CHTML).should eq @html } end end describe 'test_wiki_style3' do before do source = <<-'EOF' subTitle honbun honbun ! subTitle honbun EOF @diary.append(source) end context 'HTML' do before do @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%>
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%> <%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

honbun

<%=section_leave_proc( Time.at( 1041346800 ) )%> EOF end it { @diary.to_html({}, :CHTML).should eq @html } end end describe 'test_wiki_style_plugin' do before do source = <<-'EOF' ! subTitle {{plugin}} {{plugin}} aaa {{plugin}} a{{ho ge}}b {{ho ge}} EOF @diary.append(source) end context 'HTML' do before do @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

<%=plugin %> <%=plugin %> aaa

<%=plugin %>

a<%=ho ge %>b

<%=ho ge %>

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

<%=plugin %> <%=plugin %> aaa

<%=plugin %>

a<%=ho ge %>b

<%=ho ge %>

<%=section_leave_proc( Time.at( 1041346800 ) )%> EOF end it { @diary.to_html({}, :CHTML).should eq @html } end end describe 'test_wiki_style_kw' do before do source = <<-'EOF' ! subTitle [[aaa]] [[aaa|bbb]] [[aaa'bbb|ccc]] [[aaa|aaa]] [[aaa:鯖]] [[aaa|bbb:ccc]] [[aaa'bbb|bbb:ccc]] [[鯖|http://ja.wikipedia.org/wiki/%E9%AF%96]] http://ja.wikipedia.org/wiki/%E9%AF%96 EOF @diary.append(source) end context 'HTML' do before do @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

<%=kw 'aaa', 'aaa'%>

aaa

aaa'bbb

<%=kw 'aaa', 'aaa'%>

<%=kw 'aaa:鯖'%>

<%=kw 'bbb:ccc', 'aaa'%>

<%=kw 'bbb:ccc', 'aaa\'bbb'%>

http://ja.wikipedia.org/wiki/%E9%AF%96

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

<%=kw 'aaa', 'aaa'%>

aaa

aaa'bbb

<%=kw 'aaa', 'aaa'%>

<%=kw 'aaa:鯖'%>

<%=kw 'bbb:ccc', 'aaa'%>

<%=kw 'bbb:ccc', 'aaa\'bbb'%>

http://ja.wikipedia.org/wiki/%E9%AF%96

<%=section_leave_proc( Time.at( 1041346800 ) )%> EOF end it { @diary.to_html({}, :CHTML).should eq @html } end end describe 'test_append_without_subtitle' do before do source = <<-'EOF' ! subTitle body EOF sourceappend = <<-'EOF' appended body EOF @diary.append(source) @diary.append(sourceappend) end context 'HTML' do before do @html = <<-'EOF'
<%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

body

appended body

<%=section_leave_proc( Time.at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time.at( 1041346800 ) )%>

<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>

body

appended body

<%=section_leave_proc( Time.at( 1041346800 ) )%> EOF end it { @diary.to_html({}, :CHTML).should eq @html } end end end # Local Variables: # mode: ruby # indent-tabs-mode: t # tab-width: 3 # ruby-indent-level: 3 # End: