Skip to content

Commit 5a414ed

Browse files
authored
Use more standard rspec in cramped include spec (#792)
Replaces the more junit like tests in the cramped include spec with descriptive contexts which is more idiomatic rspec.
1 parent 937e148 commit 5a414ed

File tree

1 file changed

+30
-51
lines changed

1 file changed

+30
-51
lines changed

resources/asciidoctor/spec/cramped_include_spec.rb

Lines changed: 30 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
before(:each) do
99
Asciidoctor::Extensions.register do
1010
preprocessor CrampedInclude
11-
preprocessor ElasticCompatPreprocessor
1211
end
1312
end
1413

@@ -17,60 +16,40 @@
1716
end
1817

1918
include_examples "doesn't break line numbers"
19+
include_context 'convert without logs'
2020

21-
it "allows cramped includes of callout lists" do
22-
actual = convert <<~ASCIIDOC
23-
= Test
21+
context 'when including callout lists without a blank line between them' do
22+
let(:input) do
23+
<<~ASCIIDOC
24+
= Test
2425
25-
== Test
26+
== Test
2627
27-
include::resources/cramped_include/colist1.adoc[]
28-
include::resources/cramped_include/colist2.adoc[]
29-
ASCIIDOC
30-
expected = <<~DOCBOOK
31-
<chapter id="_test">
32-
<title>Test</title>
33-
<section id="P1">
34-
<title>P1</title>
35-
<section id="P1_1">
36-
<title>P1.1</title>
37-
<programlisting language="java" linenumbering="unnumbered">words <1> <2></programlisting>
38-
<calloutlist>
39-
<callout arearefs="CO1-1">
40-
<para>foo</para>
41-
</callout>
42-
</calloutlist>
43-
</section>
44-
</section>
45-
<section id="P2">
46-
<title>P2</title>
47-
<section id="P2_1">
48-
<title>P2.1</title>
49-
<programlisting language="java" linenumbering="unnumbered">words <1> <2></programlisting>
50-
<calloutlist>
51-
<callout arearefs="CO2-1">
52-
<para>foo</para>
53-
</callout>
54-
</calloutlist>
55-
</section>
56-
</section>
57-
</chapter>
58-
DOCBOOK
59-
expect(actual).to eq(expected.strip)
28+
include::resources/cramped_include/colist1.adoc[]
29+
include::resources/cramped_include/colist2.adoc[]
30+
ASCIIDOC
31+
end
32+
it 'renders both callout lists' do
33+
expect(converted).to include('<callout arearefs="CO1-1">')
34+
expect(converted).to include('<callout arearefs="CO2-1">')
35+
end
36+
it 'renders the sections that contain the lists' do
37+
expect(converted).to include('<title>P1</title>')
38+
expect(converted).to include('<title>P2</title>')
39+
end
6040
end
6141

62-
it "doesn't break includes of non-asciidoc files" do
63-
actual = convert <<~ASCIIDOC
64-
----
65-
include::resources/cramped_include/Example.java[]
66-
----
67-
ASCIIDOC
68-
expected = <<~DOCBOOK
69-
<preface>
70-
<title></title>
71-
<screen>public class Example {}</screen>
72-
</preface>
73-
DOCBOOK
74-
expect(actual).to eq(expected.strip)
42+
context 'when including non-asciidoc files' do
43+
let(:input) do
44+
<<~ASCIIDOC
45+
----
46+
include::resources/cramped_include/Example.java[]
47+
----
48+
ASCIIDOC
49+
end
50+
it "doesn't add an extra newline" do
51+
expect(converted).to include('<screen>public class Example {}</screen>')
52+
# If it did add an extra new line it'd be here --------------^
53+
end
7554
end
7655
end

0 commit comments

Comments
 (0)