# -*- 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'
honbun
honbun
<%=section_leave_proc( Time.at( 1041346800 ) )%>honbun
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'replace
replace
<%=section_leave_proc( Time.at( 1041346800 ) )%>honbun
honbun
<%=section_leave_proc( Time.at( 1041346800 ) )%>honbun
<%=section_leave_proc( Time.at( 1041346800 ) )%>honbun
<%=section_leave_proc( Time.at( 1041346800 ) )%><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>
honbun
honbun
<%=section_leave_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'<%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>
honbun
honbun
<%=section_leave_proc( Time.at( 1041346800 ) )%>honbun
<%=section_leave_proc( Time.at( 1041346800 ) )%><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %>
honbun
honbun
<%=section_leave_proc( Time.at( 1041346800 ) )%> <%=section_enter_proc( Time.at( 1041346800 ) )%>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'<%=plugin %> <%=plugin %> aaa
<%=plugin %>
a<%=ho ge %>b
<%=ho ge %>
<%=section_leave_proc( Time.at( 1041346800 ) )%><%=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'<%=kw 'aaa', 'aaa'%>
<%=kw 'aaa', 'aaa'%>
<%=kw 'aaa:鯖'%>
<%=kw 'bbb:ccc', 'aaa'%>
<%=kw 'bbb:ccc', 'aaa\'bbb'%>
<%=section_leave_proc( Time.at( 1041346800 ) )%><%=kw 'aaa', 'aaa'%>
<%=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'body
appended body
<%=section_leave_proc( Time.at( 1041346800 ) )%>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: