# 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'
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' EOS end it { should resemble output } end context "with an alternate to 'Chapter'" do let(:language_labels) do { "chapter" => {"word" => "fejezet", "order" => "reverse"} } end let(:pipeline) do Polytexnic::Pipeline.new(polytex, language_labels: language_labels) end let(:polytex) do <<-'EOS' \chapter{Foo \emph{bar}} \label{cha:foo} EOS end let(:output) do <<-'EOS' EOS end it { should resemble output } context "chapter, etc., linking" do let(:language_labels) do { "chapter" => {"word" => "Capítulo", "order" => "standard"}, "section" => "Sección", "table" => "Tabla", "aside" => "Caja", "figure" => "Figura", "fig" => "Fig", "listing" => "Listado", "equation" => "Ecuación", "eq" => "Ec", } end let(:polytex) do <<-'EOS' \chapter{Foo} \label{cha:foo} Capítulo~\ref{cha:foo} Sección~\ref{sec:bar} Tabla~\ref{table:bar} Caja~\ref{aside:bar} Figura~\ref{fig:bar} Fig.~\ref{fig:bar} Listado~\ref{code:bar} Ecuación~\ref{eq:bar} Ec.~\ref{eq:bar} EOS end let(:capitulo) { 'Capítulo' } let(:seccion) { 'Sección' } let(:ecuacion) { 'Ecuación' } it { should include %(class="hyperref">#{capitulo}) } it { should include %(class="hyperref">#{seccion}) } it { should include %(class="hyperref">Tabla) } it { should include %(class="hyperref">Figura) } it { should include %(class="hyperref">Fig.) } it { should include %(class="hyperref">Caja) } it { should include %(class="hyperref">Listado) } it { should include %(class="hyperref">#{ecuacion}) } it { should include %(class="hyperref">Ec.) } end end end describe '\section' do let(:polytex) do <<-'EOS' Lorem ipsum \section{Foo} \label{sec:foo} EOS end let(:output) do <<-'EOS'Lorem ipsum
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' 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' EOS end it { should resemble output } end describe '\chapter*' do let(:polytex) do <<-'EOS' \chapter*{A preface} Lorem ipsum EOS end it { should resemble '