# -*- coding: utf-8; -*- require 'spec_helper' require 'tdiary' require 'misc/style/emptdiary/emptdiary_style' describe TDiary::EmptdiaryDiary do before do @diary = TDiary::EmptdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "") end describe '#append' do before do source = <<-'EOF' subTitle

honbun

subTitle2

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

<%=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.chomp } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time::at( 1041346800 ) )%>

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

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({}, :CHTML).should eq @html } end end describe '#replace' do before do source = <<-'EOF' subTitle

honbun

subTitle2

honbun

EOF @diary.append(source) replaced = <<-'EOF' replaceTitle

replace

replaceTitle2

replace

EOF @diary.replace(Time::at( 1041346800 ), "TITLE", replaced) @html = <<-'EOF'
<%=section_enter_proc( Time::at( 1041346800 ) )%>

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

replace

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

<%= subtitle_proc( Time::at( 1041346800 ), "replaceTitle2" ) %>

replace

<%=section_leave_proc( Time::at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html.chomp } end describe 'test_emptdiary_style_plugin' do before do source = <<-'EOF' sectionTitle

body

<%=pre <<'_PRE' #include /* comment */ int main (int argc, char *argv[]) { puts ("Hello world."); } _PRE %> EOF @diary.append(source) end context 'HTML' do before do @html = <<-'EOF'
<%=section_enter_proc( Time::at( 1041346800 ) )%>

<%= subtitle_proc( Time::at( 1041346800 ), "sectionTitle" ) %>

body

<%=pre <<'_PRE' #include /* comment */ int main (int argc, char *argv[]) { puts ("Hello world."); } _PRE %><%=section_leave_proc( Time::at( 1041346800 ) )%>
EOF end it { @diary.to_html.should eq @html.chomp } end context 'CHTML' do before do @html = <<-'EOF' <%=section_enter_proc( Time::at( 1041346800 ) )%>

<%= subtitle_proc( Time::at( 1041346800 ), "sectionTitle" ) %>

body

<%=pre <<'_PRE' #include /* comment */ int main (int argc, char *argv[]) { puts ("Hello world."); } _PRE %><%=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: