require 'spec_helper' module Hemingway describe Parser do before do @parser = Parser.new time = double() Time.stub(:now) { time } time.stub(:to_f) { 100.01 } end describe "#footnote" do it "should put a footnote at the end of a paragraph" do html = @parser.parse("You are what you redpoint\\footnote{sending a lead route}, after all.").html html.should == "

You are what you redpoint1, after all.

1sending a lead route
" end it "should put properly increment the footnote count per entry" do html = @parser.parse("Slowly, Vader\\footnote{thug} approached Luke\\footnote{homeboy}").html html.should == "

Slowly, Vader1 approached Luke2

1thug
2homeboy
" end it "should support any type of content in a footnote" do html = @parser.parse("Dave Graham\\footnote{\\emph{Boulderer}, and \& all around \\textsc{good} guy $\\gamma$} makes the best mixtapes").html html.should == "

Dave Graham1 makes the best mixtapes

1Boulderer, and & all around good guy γ
" end it "should properly place footnotes from all paragraphs after all paragraphs an increment properly" do html = @parser.parse("Freddie Gibbs\\footnote{from Gary, Indiana} is hood\\footnote{thug} as all hell.\n\n John Russel\\footnote{of Short Bus fame} almost got raped in Gary, ID\\footnote{but not by Freddie Gibbs}").html html.should == "

Freddie Gibbs1 is hood2 as all hell.

John Russel3 almost got raped in Gary, ID4

1from Gary, Indiana
2thug
3of Short Bus fame
4but not by Freddie Gibbs
" end it "will obviously allow me to drop a list in a footnote (this is just for my own satisfaction mostly)" do html = @parser.parse("There are some rules\\footnote{\\begin{itemize} \\item Steezy socks always \\item Brosend often \\item Everything for the ladies \\end{itemize}} that we all must live by.").html html.should == "

There are some rules1 that we all must live by.

1
" end end end end