Skip to content

Commit

Permalink
Added a missing spec and tested convert_dd when given index:.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Dec 4, 2023
1 parent 3357285 commit c612711
Showing 1 changed file with 56 additions and 32 deletions.
88 changes: 56 additions & 32 deletions spec/converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,39 @@
)
end
end

context "when there are multiple definitions for a term" do
let(:term) { "foo" }
let(:definition1) { "Foo bar." }
let(:definition2) { "Baz qux." }
let(:markdown) do
<<~MARKDOWN
#{term}
: #{definition1}
: #{definition2}
MARKDOWN
end

let(:dl) { doc.root.children[0] }

let(:escaped_definition1) { definition1.gsub('.',"\\.") }
let(:escaped_definition2) { definition2.gsub('.',"\\.") }

it "must convert the following p children into '.RS\\n.PP\\n...\\n.RE'" do
expect(subject.convert_dl(dl)).to eq(
<<~ROFF
.TP
#{term}
#{escaped_definition1}
.RS
.PP
#{escaped_definition2}
.RE
ROFF
)
end
end
end

describe "#convert_dt" do
Expand Down Expand Up @@ -495,11 +528,8 @@
)
end

context "when the dd element is the first dd element following a dt element" do
context "when the given index: is 0" do
context "and when the dd element contains multiple p children" do
let(:word1) { "foo" }
let(:word2) { "bar" }
let(:word3) { "baz" }
let(:word4) { "qux" }
let(:definition1) { "#{word1} #{word2}" }
let(:definition2) { "`#{word3}` *#{word4}*" }
Expand All @@ -524,40 +554,34 @@
)
end
end
end

context "and when the dd element contains multiple p children" do
let(:word1) { "foo" }
let(:word2) { "bar" }
let(:word3) { "baz" }
let(:word4) { "qux" }
let(:definition1) { "#{word1} #{word2}" }
let(:definition2) { "`#{word3}` *#{word4}*" }
let(:markdown) do
<<~MARKDOWN
#{term}
: #{definition1}
context "when the given index: is greater than 0" do
let(:word4) { "qux" }
let(:definition1) { "#{word1} #{word2}" }
let(:definition2) { "`#{word3}` *#{word4}*" }
let(:markdown) do
<<~MARKDOWN
#{term}
: #{definition1}
: #{definition2}
MARKDOWN
end
: #{definition2}
MARKDOWN
end

let(:dd) { doc.root.children[0].children[2] }
let(:dd) { doc.root.children[0].children[2] }

it "must convert the following p children into '.RS\\n.PP\\n...\\n.RE'" do
expect(subject.convert_dd(dd, index: 1)).to eq(
<<~ROFF
.RS
.PP
\\fB#{word3}\\fR \\fI#{word4}\\fP
.RE
ROFF
)
end
it "must convert the child elements into '.RS\\n...\\n.RE'" do
expect(subject.convert_dd(dd, index: 1)).to eq(
<<~ROFF
.RS
.PP
\\fB#{word3}\\fR \\fI#{word4}\\fP
.RE
ROFF
)
end
end

context "when the dd element follows a previous dd element" do
end
end

describe "#convert_abbreviation" do
Expand Down

0 comments on commit c612711

Please sign in to comment.