spec/kramdown/converter/man_spec.rb in kramdown-man-0.1.5 vs spec/kramdown/converter/man_spec.rb in kramdown-man-0.1.6
- old
+ new
@@ -18,17 +18,17 @@
}.strip)
end
let(:root) { doc.root }
it "should add the header" do
- subject.convert(root).should == [
+ expect(subject.convert(root)).to eq([
described_class::HEADER,
".TH Header",
".LP",
".PP",
'Hello world\.'
- ].join("\n")
+ ].join("\n"))
end
end
describe "#convert_root" do
let(:doc) do
@@ -40,252 +40,252 @@
end
let(:root) { doc.root }
it "should convert every element" do
- subject.convert_root(root).should == [
+ expect(subject.convert_root(root)).to eq([
".TH Header",
".LP",
".PP",
'Hello world\.'
- ].join("\n")
+ ].join("\n"))
end
end
describe "#convert_element" do
let(:doc) { Kramdown::Document.new(" puts 'hello'") }
let(:el) { doc.root.children[0] }
it "should convert the element based on it's type" do
- subject.convert_element(el).should == subject.convert_codeblock(el)
+ expect(subject.convert_element(el)).to eq(subject.convert_codeblock(el))
end
end
describe "#convert_blank" do
let(:doc) { Kramdown::Document.new("foo\n\nbar") }
let(:blank) { doc.root.children[0].children[1] }
it "should convert blank elements to '.LP'" do
- subject.convert_blank(blank).should == '.LP'
+ expect(subject.convert_blank(blank)).to eq('.LP')
end
end
describe "#convert_text" do
let(:content) { 'Foo bar' }
let(:doc) { Kramdown::Document.new(content) }
let(:text) { doc.root.children[0].children[0] }
it "should convert text elements" do
- subject.convert_text(text).should == content
+ expect(subject.convert_text(text)).to eq(content)
end
context "when the text has two-space indentation" do
let(:content) { "Foo\n bar\n baz" }
it "should strip leading whitespace from each line" do
- subject.convert_text(text).should == content.gsub("\n ","\n")
+ expect(subject.convert_text(text)).to eq(content.gsub("\n ","\n"))
end
end
context "when the text has tab indentation" do
let(:content) { "Foo\n\tbar\n\tbaz" }
it "should strip leading whitespace from each line" do
- subject.convert_text(text).should == content.gsub("\n\t","\n")
+ expect(subject.convert_text(text)).to eq(content.gsub("\n\t","\n"))
end
end
end
describe "#convert_typographic_sym" do
context "ndash" do
let(:doc) { Kramdown::Document.new("-- foo") }
let(:sym) { doc.root.children[0].children[0] }
it "should convert ndash symbols back into '\-\-'" do
- subject.convert_typographic_sym(sym).should == "\\-\\-"
+ expect(subject.convert_typographic_sym(sym)).to eq("\\-\\-")
end
end
context "mdash" do
let(:doc) { Kramdown::Document.new("--- foo") }
let(:sym) { doc.root.children[0].children[0] }
it "should convert mdash symbols into '\[em]'" do
- subject.convert_typographic_sym(sym).should == '\[em]'
+ expect(subject.convert_typographic_sym(sym)).to eq('\[em]')
end
end
context "hellip" do
let(:doc) { Kramdown::Document.new("... foo") }
let(:sym) { doc.root.children[0].children[0] }
- it "should convert mdash symbols into '...'" do
- subject.convert_typographic_sym(sym).should == '...'
+ it "should convert mdash symbols into '\\.\\.\\.'" do
+ expect(subject.convert_typographic_sym(sym)).to eq('\.\.\.')
end
end
context "laquo" do
let(:doc) { Kramdown::Document.new("<< foo") }
let(:sym) { doc.root.children[0].children[0] }
it "should convert mdash symbols into '\[Fo]'" do
- subject.convert_typographic_sym(sym).should == '\[Fo]'
+ expect(subject.convert_typographic_sym(sym)).to eq('\[Fo]')
end
end
context "raquo" do
let(:doc) { Kramdown::Document.new("foo >> bar") }
let(:sym) { doc.root.children[0].children[1] }
it "should convert mdash symbols into '\[Fc]'" do
- subject.convert_typographic_sym(sym).should == '\[Fc]'
+ expect(subject.convert_typographic_sym(sym)).to eq('\[Fc]')
end
end
context "laquo_space" do
let(:doc) { Kramdown::Document.new(" << foo") }
let(:sym) { doc.root.children[0].children[0] }
it "should convert mdash symbols into '\[Fo]'" do
- subject.convert_typographic_sym(sym).should == '\[Fo]'
+ expect(subject.convert_typographic_sym(sym)).to eq('\[Fo]')
end
end
context "raquo_space" do
let(:doc) { Kramdown::Document.new("foo >> bar") }
let(:sym) { doc.root.children[0].children[1] }
it "should convert mdash symbols into '\[Fc]'" do
- subject.convert_typographic_sym(sym).should == '\[Fc]'
+ expect(subject.convert_typographic_sym(sym)).to eq('\[Fc]')
end
end
end
describe "#convert_smart_quote" do
context "lsquo" do
let(:doc) { Kramdown::Document.new("'hello world'") }
let(:quote) { doc.root.children[0].children.first }
it "should convert lsquo quotes into '\[oq]'" do
- subject.convert_smart_quote(quote).should == '\[oq]'
+ expect(subject.convert_smart_quote(quote)).to eq('\[oq]')
end
end
context "rsquo" do
let(:doc) { Kramdown::Document.new("'hello world'") }
let(:quote) { doc.root.children[0].children.last }
it "should convert rsquo quotes into '\[cq]'" do
- subject.convert_smart_quote(quote).should == '\[cq]'
+ expect(subject.convert_smart_quote(quote)).to eq('\[cq]')
end
end
context "ldquo" do
let(:doc) { Kramdown::Document.new('"hello world"') }
let(:quote) { doc.root.children[0].children.first }
it "should convert lsquo quotes into '\[lq]'" do
- subject.convert_smart_quote(quote).should == '\[lq]'
+ expect(subject.convert_smart_quote(quote)).to eq('\[lq]')
end
end
context "rdquo" do
let(:doc) { Kramdown::Document.new('"hello world"') }
let(:quote) { doc.root.children[0].children.last }
it "should convert lsquo quotes into '\[rq]'" do
- subject.convert_smart_quote(quote).should == '\[rq]'
+ expect(subject.convert_smart_quote(quote)).to eq('\[rq]')
end
end
end
describe "#convert_header" do
context "when level is 1" do
let(:doc) { Kramdown::Document.new("# Header") }
let(:header) { doc.root.children[0] }
it "should convert level 1 headers into '.TH text'" do
- subject.convert_header(header).should == ".TH Header"
+ expect(subject.convert_header(header)).to eq(".TH Header")
end
end
context "when level is 2" do
let(:doc) { Kramdown::Document.new("## Header") }
let(:header) { doc.root.children[0] }
it "should convert level 2 headers into '.SH text'" do
- subject.convert_header(header).should == ".SH Header"
+ expect(subject.convert_header(header)).to eq(".SH Header")
end
end
context "when level is 3" do
let(:doc) { Kramdown::Document.new("### Header") }
let(:header) { doc.root.children[0] }
it "should convert level 2 headers into '.SS text'" do
- subject.convert_header(header).should == ".SS Header"
+ expect(subject.convert_header(header)).to eq(".SS Header")
end
end
context "when level is 4 or greater" do
let(:doc) { Kramdown::Document.new("#### Header") }
let(:header) { doc.root.children[0] }
it "should convert level 2 headers into '.SS text'" do
- subject.convert_header(header).should == ".SS Header"
+ expect(subject.convert_header(header)).to eq(".SS Header")
end
end
end
describe "#convert_hr" do
let(:doc) { Kramdown::Document.new('------------------------------------') }
let(:hr) { doc.root.children[0] }
it "should convert hr elements into '.ti 0\\n\\\\l'\\\\n(.lu\\''" do
- subject.convert_hr(hr).should == ".ti 0\n\\l'\\n(.lu'"
+ expect(subject.convert_hr(hr)).to eq(".ti 0\n\\l'\\n(.lu'")
end
end
describe "#convert_ul" do
let(:text1) { 'foo' }
let(:text2) { 'bar' }
let(:doc) { Kramdown::Document.new("* #{text1}\n* #{text2}") }
let(:ul) { doc.root.children[0] }
it "should convert ul elements into '.RS\\n...\\n.RE'" do
- subject.convert_ul(ul).should == [
+ expect(subject.convert_ul(ul)).to eq([
".RS",
".IP \\(bu 2",
text1,
".IP \\(bu 2",
text2,
".RE"
- ].join("\n")
+ ].join("\n"))
end
end
describe "#convert_ul_li" do
let(:text) { 'hello world' }
let(:doc) { Kramdown::Document.new("* #{text}") }
let(:li) { doc.root.children[0].children[0] }
it "should convert the first p element to '.IP \\\\(bu 2\\n...'" do
- subject.convert_ul_li(li).should == ".IP \\(bu 2\n#{text}"
+ expect(subject.convert_ul_li(li)).to eq(".IP \\(bu 2\n#{text}")
end
context "with multiple multiple paragraphs" do
let(:text1) { 'hello' }
let(:text2) { 'world' }
let(:doc) { Kramdown::Document.new("* #{text1}\n\n #{text2}") }
it "should convert the other p elements to '.IP \\\\( 2\\n...'" do
- subject.convert_ul_li(li).should == [
+ expect(subject.convert_ul_li(li)).to eq([
".IP \\(bu 2",
text1,
".IP \\( 2",
text2
- ].join("\n")
+ ].join("\n"))
end
end
end
describe "#convert_ol" do
@@ -293,43 +293,43 @@
let(:text2) { 'bar' }
let(:doc) { Kramdown::Document.new("1. #{text1}\n2. #{text2}") }
let(:ol) { doc.root.children[0] }
it "should convert ol elements into '.RS\\n...\\n.RE'" do
- subject.convert_ol(ol).should == [
+ expect(subject.convert_ol(ol)).to eq([
".nr step1 0 1",
".RS",
".IP \\n+[step1]",
text1,
".IP \\n+[step1]",
text2,
".RE"
- ].join("\n")
+ ].join("\n"))
end
end
describe "#convert_ol_li" do
let(:text) { 'hello world' }
let(:doc) { Kramdown::Document.new("1. #{text}") }
let(:li) { doc.root.children[0].children[0] }
it "should convert the first p element to '.IP \\\\n+[step0]\\n...'" do
- subject.convert_ol_li(li).should == ".IP \\n+[step0]\n#{text}"
+ expect(subject.convert_ol_li(li)).to eq(".IP \\n+[step0]\n#{text}")
end
context "with multiple multiple paragraphs" do
let(:text1) { 'hello' }
let(:text2) { 'world' }
let(:doc) { Kramdown::Document.new("1. #{text1}\n\n #{text2}") }
it "should convert the other p elements to '.IP \\\\n\\n...'" do
- subject.convert_ol_li(li).should == [
+ expect(subject.convert_ol_li(li)).to eq([
".IP \\n+[step0]",
text1,
".IP \\n",
text2
- ].join("\n")
+ ].join("\n"))
end
end
end
describe "#convert_abbreviation" do
@@ -337,89 +337,89 @@
let(:definition) { 'Hyper Text Markup Language' }
let(:doc) { Kramdown::Document.new("This is an #{acronym} example.\n\n*[#{acronym}]: #{definition}") }
let(:abbreviation) { doc.root.children[0].children[1] }
it "should convert abbreviation elements into their text" do
- subject.convert_abbreviation(abbreviation).should == acronym
+ expect(subject.convert_abbreviation(abbreviation)).to eq(acronym)
end
end
describe "#convert_blockquote" do
let(:text) { "Some quote." }
let(:escaped_text) { 'Some quote\.' }
let(:doc) { Kramdown::Document.new("> #{text}") }
let(:blockquote) { doc.root.children[0] }
it "should convert blockquote elements into '.PP\\n.RS\\ntext...\\n.RE'" do
- subject.convert_blockquote(blockquote).should == ".PP\n.RS\n#{escaped_text}\n.RE"
+ expect(subject.convert_blockquote(blockquote)).to eq(".PP\n.RS\n#{escaped_text}\n.RE")
end
end
describe "#convert_codeblock" do
let(:code) { "puts 'hello world'" }
let(:escaped_code) { 'puts \(aqhello world\(aq' }
let(:doc) { Kramdown::Document.new(" #{code}\n") }
let(:codeblock) { doc.root.children[0] }
it "should convert codeblock elements into '.nf\\ntext...\\n.fi'" do
- subject.convert_codeblock(codeblock).should == ".nf\n#{escaped_code}\n.fi"
+ expect(subject.convert_codeblock(codeblock)).to eq(".nf\n#{escaped_code}\n.fi")
end
end
describe "#convert_comment" do
let(:text) { "Copyright (c) 2013" }
let(:doc) { Kramdown::Document.new("{::comment}\n#{text}\n{:/comment}") }
let(:comment) { doc.root.children[0] }
it "should convert comment elements into '.\\\" text...'" do
- subject.convert_comment(comment).should == ".\\\" #{text}"
+ expect(subject.convert_comment(comment)).to eq(".\\\" #{text}")
end
end
describe "#convert_p" do
let(:text) { "Hello world." }
let(:escaped_text) { 'Hello world\.' }
let(:doc) { Kramdown::Document.new(text) }
let(:p) { doc.root.children[0] }
it "should convert p elements into '.PP\\ntext'" do
- subject.convert_p(p).should == ".PP\n#{escaped_text}"
+ expect(subject.convert_p(p)).to eq(".PP\n#{escaped_text}")
end
context "when the paragraph starts with a codespan element" do
let(:option) { '--foo' }
let(:text) { 'Foo bar baz' }
let(:doc) { Kramdown::Document.new("`#{option}`\n\t#{text}") }
it "should convert p elements into '.TP\\n\\fB--option\\fR\\ntext...'" do
- subject.convert_p(p).should == ".TP\n\\fB#{option}\\fR\n#{text}"
+ expect(subject.convert_p(p)).to eq(".TP\n\\fB#{option}\\fR\n#{text}")
end
context "when there is only one codespan element" do
let(:code) { 'code' }
let(:doc) { Kramdown::Document.new("`#{code}`") }
it "should convert p elements into '.PP\\n\\fB...\\fR'" do
- subject.convert_p(p).should == ".PP\n\\fB#{code}\\fR"
+ expect(subject.convert_p(p)).to eq(".PP\n\\fB#{code}\\fR")
end
end
context "when there are more than one codespan element" do
let(:flag) { '-f' }
let(:option) { '--foo' }
let(:text) { 'Foo bar baz' }
let(:doc) { Kramdown::Document.new("`#{flag}`, `#{option}`\n\t#{text}") }
it "should convert p elements into '.TP\\n\\fB-o\\fR, \\fB--option\\fR\\ntext...'" do
- subject.convert_p(p).should == ".TP\n\\fB#{flag}\\fR, \\fB#{option}\\fR\n#{text}"
+ expect(subject.convert_p(p)).to eq(".TP\n\\fB#{flag}\\fR, \\fB#{option}\\fR\n#{text}")
end
context "when there is no newline" do
let(:doc) { Kramdown::Document.new("`#{flag}` `#{option}`") }
it "should convert the p element into a '.HP\\n...'" do
- subject.convert_p(p).should == ".HP\n\\fB#{flag}\\fR \\fB#{option}\\fR"
+ expect(subject.convert_p(p)).to eq(".HP\n\\fB#{flag}\\fR \\fB#{option}\\fR")
end
end
end
end
@@ -431,19 +431,19 @@
let(:doc) do
Kramdown::Document.new("*#{option}*\n\t#{text}")
end
it "should convert p elements into '.TP\\n\\fI--option\\fP\\ntext...'" do
- subject.convert_p(p).should == ".TP\n\\fI#{escaped_option}\\fP\n#{text}"
+ expect(subject.convert_p(p)).to eq(".TP\n\\fI#{escaped_option}\\fP\n#{text}")
end
context "when there is only one em element" do
let(:text) { 'foo' }
let(:doc) { Kramdown::Document.new("*#{text}*") }
it "should convert p elements into '.PP\\n\\fI...\\fP'" do
- subject.convert_p(p).should == ".PP\n\\fI#{text}\\fP"
+ expect(subject.convert_p(p)).to eq(".PP\n\\fI#{text}\\fP")
end
end
context "when there are more than one em element" do
let(:flag) { '-f' }
@@ -453,18 +453,18 @@
let(:doc) do
Kramdown::Document.new("*#{flag}*, *#{option}*\n\t#{text}")
end
it "should convert p elements into '.TP\\n\\fI-o\\fP, \\fI\\-\\-option\\fP\\ntext...'" do
- subject.convert_p(p).should == ".TP\n\\fI#{escaped_flag}\\fP, \\fI#{escaped_option}\\fP\n#{text}"
+ expect(subject.convert_p(p)).to eq(".TP\n\\fI#{escaped_flag}\\fP, \\fI#{escaped_option}\\fP\n#{text}")
end
context "when there is no newline" do
let(:doc) { Kramdown::Document.new("*#{flag}* *#{option}*") }
it "should convert the p element into a '.HP\\n...'" do
- subject.convert_p(p).should == ".HP\n\\fI#{escaped_flag}\\fP \\fI#{escaped_option}\\fP"
+ expect(subject.convert_p(p)).to eq(".HP\n\\fI#{escaped_flag}\\fP \\fI#{escaped_option}\\fP")
end
end
end
end
end
@@ -473,31 +473,31 @@
let(:text) { "hello world" }
let(:doc) { Kramdown::Document.new("*#{text}*") }
let(:em) { doc.root.children[0].children[0] }
it "should convert em elements into '\\fItext\\fP'" do
- subject.convert_em(em).should == "\\fI#{text}\\fP"
+ expect(subject.convert_em(em)).to eq("\\fI#{text}\\fP")
end
end
describe "#convert_strong" do
let(:text) { "hello world" }
let(:doc) { Kramdown::Document.new("**#{text}**") }
let(:strong) { doc.root.children[0].children[0] }
it "should convert strong elements into '\\fBtext\\fP'" do
- subject.convert_strong(strong).should == "\\fB#{text}\\fP"
+ expect(subject.convert_strong(strong)).to eq("\\fB#{text}\\fP")
end
end
describe "#convert_codespan" do
let(:code) { "puts 'hello world'" }
let(:doc) { Kramdown::Document.new("`#{code}`") }
let(:codespan) { doc.root.children[0].children[0] }
it "should convert codespan elements into '\\fBcode\\fR'" do
- subject.convert_codespan(codespan).should == "\\fB#{code}\\fR"
+ expect(subject.convert_codespan(codespan)).to eq("\\fB#{code}\\fR")
end
end
describe "#convert_a" do
let(:text) { 'example' }
@@ -505,56 +505,56 @@
let(:escaped_href) { 'http:\[sl]\[sl]example\.com\[sl]' }
let(:doc) { Kramdown::Document.new("[#{text}](#{href})") }
let(:link) { doc.root.children[0].children[0] }
it "should convert a link elements into 'text\\n.UR href\\n.UE'" do
- subject.convert_a(link).should == "#{text}\n.UR #{escaped_href}\n.UE"
+ expect(subject.convert_a(link)).to eq("#{text}\n.UR #{escaped_href}\n.UE")
end
context "when the href begins with mailto:" do
let(:text) { 'Bob' }
let(:email) { 'bob@example.com' }
let(:escaped_email) { 'bob\[at]example\.com' }
let(:doc) { Kramdown::Document.new("[#{text}](mailto:#{email})") }
it "should convert the link elements into '.MT email\\n.ME'" do
- subject.convert_a(link).should == "#{text}\n.MT #{escaped_email}\n.ME"
+ expect(subject.convert_a(link)).to eq("#{text}\n.MT #{escaped_email}\n.ME")
end
context "when link is <email>" do
let(:doc) { Kramdown::Document.new("<#{email}>") }
it "should convert the link elements into '.MT email\\n.ME'" do
- subject.convert_a(link).should == "\n.MT #{escaped_email}\n.ME"
+ expect(subject.convert_a(link)).to eq("\n.MT #{escaped_email}\n.ME")
end
end
end
context "when the href begins with man:" do
let(:man) { 'bash' }
let(:doc) { Kramdown::Document.new("[#{man}](man:#{man})") }
it "should convert the link elements into '.BR man'" do
- subject.convert_a(link).should == "\n.BR #{man}"
+ expect(subject.convert_a(link)).to eq("\n.BR #{man}")
end
context "when a section number is specified" do
let(:section) { '1' }
let(:doc) { Kramdown::Document.new("[#{man}](man:#{man}(#{section}))") }
it "should convert the link elements into '.BR man (section)'" do
- subject.convert_a(link).should == "\n.BR #{man} (#{section})"
+ expect(subject.convert_a(link)).to eq("\n.BR #{man} (#{section})")
end
end
end
end
describe "#escape" do
let(:text) { "hello\nworld" }
described_class::GLYPHS.each do |char,glyph|
it "should convert #{char.dump} into #{glyph.dump}" do
- subject.escape("#{text} #{char}").should == "#{text} #{glyph}"
+ expect(subject.escape("#{text} #{char}")).to eq("#{text} #{glyph}")
end
end
end
end