# encoding=utf-8 require 'spec_helper' describe 'Polytexnic::Pipeline#to_html' do let(:pipeline) { Polytexnic::Pipeline.new(polytex) } subject(:processed_text) { pipeline.to_html } describe '\chapter' do context "with a name" do let(:polytex) do <<-'EOS' \chapter{Foo \emph{bar}} \label{cha:foo} EOS end let(:output) do <<-'EOS'

Chapter 1 Foo bar

EOS end it { should resemble output } end context "with no name" do let(:polytex) do <<-'EOS' \chapter{} \label{cha:foo} EOS end let(:output) do <<-'EOS'

Chapter 1

EOS end it { should resemble output } end context "with an alternate to 'Chapter'" do before do pipeline.stub(:custom_commands). and_return('\renewcommand{\chaptername}{Chapitre}') end let(:polytex) do <<-'EOS' \chapter{Foo \emph{bar}} \label{cha:foo} EOS end let(:output) do <<-'EOS'

Chapitre 1 Foo bar

EOS end it { should resemble output } end end describe '\section' do let(:polytex) do <<-'EOS' \section{Foo} \label{sec:foo} EOS end let(:output) do <<-'EOS'

1 Foo

EOS end it { should resemble output } end describe '\subsection' do let(:polytex) do <<-'EOS' \section{Foo} \label{sec:foo} \subsection{Bar} \label{sec:bar} EOS end let(:output) do <<-'EOS'

1 Foo

1.1 Bar

EOS end it { should resemble output } end describe '\subsubsection' do let(:polytex) do <<-'EOS' \chapter{The Chapter} \label{cha:the_chapter} \section{Foo} \label{sec:foo} \subsection{Bar} \label{sec:bar} \subsubsection{Baz} \label{sec:baz} EOS end let(:output) do <<-'EOS'

Chapter 1 The Chapter

1.1 Foo

1.1.1 Bar

EOS end it { should resemble output } end describe '\chapter*' do let(:polytex) do <<-'EOS' \chapter*{Preface} Lorem ipsum EOS end it { should resemble '
' } end describe '\section*, etc.' do let(:polytex) do <<-'EOS' \section*{Foo} \subsection*{Bar} Lorem ipsum \section{Baz} EOS end let(:output) do <<-'EOS'

Foo

Bar

Lorem ipsum

1 Baz

EOS end it { should resemble output } end describe 'chapter cross-references' do let(:polytex) do <<-'EOS' \chapter{Foo} \label{cha:foo_bar} Chapter~\ref{cha:foo_bar} and Chapter \ref{cha:foo_baz} \chapter{Baz} \label{cha:foo_baz} Chapter~\ref{cha:foo_baz} and Chapter \ref{cha:foo_bar} EOS end it do should resemble <<-'EOS'

Chapter 1 Foo

Chapter 1 and Chapter 2

Chapter 2 Baz

Chapter 2 and Chapter 1

EOS end end describe "section cross-references" do let(:polytex) do <<-'EOS' \section{Foo} \label{sec:foo} Section~\ref{sec:bar} and Section~\ref{sec:baz} \subsection{Bar} \label{sec:bar} Section~\ref{sec:foo} \subsubsection{Baz} \label{sec:baz} EOS end it do should resemble <<-'EOS'

1 Foo

Section 1.1 and Section 1.1.1

EOS end end describe 'missing cross-references' do let(:polytex) do <<-'EOS' \chapter{Foo} \label{cha:foo} Chapter~\ref{cha:bar} EOS end it do should resemble <<-'EOS'

Chapter 1 Foo

Chapter cha:bar

EOS end end describe "frontmatter and mainmatter" do let(:polytex) do <<-'EOS' \frontmatter \chapter{Foo} Lorem ipsum.\footnote{Foo bar.} \mainmatter \chapter{Bar} \label{cha:bar} Chapter~\ref{cha:bar} EOS end it do should resemble <<-'EOS'

Foo

Lorem ipsum.1

  1. Foo bar. 

Chapter 1 Bar

Chapter 1

EOS end end end