asciidoctor-doctest 2.0.0.beta.4 → 2.0.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.adoc +58 -0
  3. data/LICENSE +21 -0
  4. data/README.adoc +310 -0
  5. data/asciidoctor-doctest.gemspec +48 -0
  6. data/data/examples/asciidoc/embedded.adoc +15 -0
  7. data/data/examples/asciidoc/preamble.adoc +1 -2
  8. data/data/examples/asciidoc/section.adoc +9 -0
  9. data/data/examples/asciidoc/toc.adoc +21 -9
  10. data/lib/asciidoctor/doctest/html/converter.rb +1 -1
  11. data/lib/asciidoctor/doctest/io/asciidoc.rb +2 -3
  12. data/lib/asciidoctor/doctest/io/base.rb +1 -1
  13. data/lib/asciidoctor/doctest/io/xml.rb +1 -1
  14. data/lib/asciidoctor/doctest/test_reporter.rb +3 -3
  15. data/lib/asciidoctor/doctest/version.rb +1 -1
  16. metadata +20 -69
  17. data/doc/img/doctest-diag.odf +0 -0
  18. data/doc/img/doctest-diag.svg +0 -56
  19. data/doc/img/failing-test-term.gif +0 -0
  20. data/features/README +0 -1
  21. data/features/fixtures/html-slim/Rakefile +0 -9
  22. data/features/fixtures/html-slim/examples/asciidoc/document.adoc +0 -4
  23. data/features/fixtures/html-slim/examples/asciidoc/inline_quoted.adoc +0 -2
  24. data/features/fixtures/html-slim/examples/asciidoc/quote.adoc +0 -12
  25. data/features/fixtures/html-slim/examples/html/document.html +0 -7
  26. data/features/fixtures/html-slim/examples/html/quote.html +0 -26
  27. data/features/fixtures/html-slim/templates/document.html.slim +0 -13
  28. data/features/fixtures/html-slim/templates/embedded.html.slim +0 -3
  29. data/features/fixtures/html-slim/templates/inline_quoted.html.slim +0 -8
  30. data/features/fixtures/html-slim/templates/paragraph.html.slim +0 -1
  31. data/features/fixtures/html-slim/templates/quote.html.slim +0 -7
  32. data/features/generator_html.feature +0 -171
  33. data/features/step_definitions/doctest_steps.rb +0 -5
  34. data/features/support/env.rb +0 -24
  35. data/features/test_html.feature +0 -98
  36. data/spec/asciidoc_converter_spec.rb +0 -64
  37. data/spec/example_spec.rb +0 -180
  38. data/spec/factory_spec.rb +0 -46
  39. data/spec/html/converter_spec.rb +0 -137
  40. data/spec/html_normalizer_spec.rb +0 -70
  41. data/spec/io/asciidoc_spec.rb +0 -139
  42. data/spec/io/xml_spec.rb +0 -141
  43. data/spec/minitest_diffy_spec.rb +0 -59
  44. data/spec/no_fallback_template_converter_spec.rb +0 -38
  45. data/spec/shared_examples/base_examples.rb +0 -289
  46. data/spec/spec_helper.rb +0 -39
  47. data/spec/support/matchers.rb +0 -7
  48. data/spec/tester_spec.rb +0 -153
@@ -1,13 +0,0 @@
1
- doctype 5
2
- html lang=(attr :lang, 'en' unless attr? :nolang)
3
- head
4
- meta charset='UTF-8'
5
- title=((doctitle sanitize: true) || (attr 'untitled-label'))
6
- body
7
- - unless noheader && notitle
8
- #header
9
- h1 =header.title
10
- - if attr? :author
11
- .details
12
- span#author =(attr :author)
13
- #content =content
@@ -1,3 +0,0 @@
1
- - unless notitle || !has_header?
2
- h1 id=id =header.title
3
- =content
@@ -1,8 +0,0 @@
1
- - case type
2
- - when :emphasis
3
- em class=role =text
4
- - when :strong
5
- strong class=role =text
6
- - else
7
- .span class=role
8
- =text
@@ -1,7 +0,0 @@
1
- *{:tag=>(title.nil_or_empty? ? 'div' : 'section'), :id=>id, :class=>['quoteblock', *role]}
2
- - unless title.nil_or_empty?
3
- h6 =captioned_title
4
- blockquote =content
5
- - if attr? :attribution
6
- .attribution
7
- | — #{attr :attribution}
@@ -1,171 +0,0 @@
1
- Feature: Generating output examples for a custom HTML backend
2
-
3
- Background:
4
- Given I do have a template-based HTML backend with DocTest
5
-
6
- Scenario: Generate missing output examples
7
- When I run `bundle exec rake doctest:generate`
8
- Then the output should contain:
9
- """
10
- Generating test examples *:* in examples/html
11
- --> Skipping document:title-with-author
12
- --> Generating inline_quoted:emphasis
13
- --> Unchanged quote:with-id-and-role
14
- --> Generating quote:with-title
15
- --> Skipping quote:with-attribution
16
- --> Unknown quote:basic, doesn't exist in input examples!
17
-
18
- """
19
- And the file "examples/html/quote.html" should contain exactly:
20
- """
21
- <!-- .basic
22
- Doesn't exist in input examples.
23
- -->
24
- <div class="quoteblock">
25
- <blockquote>Four score and seven years ago our fathers brought forth
26
- on this continent a new nation&#8230;&#8203;</blockquote>
27
- </div>
28
-
29
- <!-- .with-id-and-role
30
- Correct example.
31
- -->
32
- <div id="parking"
33
- class="quoteblock startrek">
34
- <blockquote>
35
- Everybody remember
36
- where we parked.
37
- </blockquote>
38
- </div>
39
-
40
- <!-- .with-attribution
41
- Failing example.
42
- -->
43
- <div class="quoteblock">
44
- <blockquote>A person who never made a mistake <em>never</em> tried anything new.</blockquote>
45
- <div>Albert Einstein</div>
46
- </div>
47
-
48
- <!-- .with-title -->
49
- <section class="quoteblock">
50
- <h6>After landing the cloaked Klingon bird of prey in Golden Gate park:</h6>
51
- <blockquote>Everybody remember where we parked.</blockquote>
52
- </section>
53
-
54
- """
55
- And the file "examples/html/document.html" should contain exactly:
56
- """
57
- <!-- .title-with-author
58
- :include: .//body/div[@id="header"]
59
- -->
60
- <div id="header">
61
- <h1>The Dangerous and Thrilling Documentation Chronicles</h1>
62
- <div id="author">Kismet Rainbow Chameleon</div>
63
- </div>
64
-
65
- """
66
- And the file "examples/html/inline_quoted.html" should contain exactly:
67
- """
68
- <!-- .emphasis -->
69
- <em>chunky bacon</em>
70
-
71
- """
72
-
73
- Scenario: Regenerate all outdated output examples
74
- When I run `bundle exec rake doctest:generate FORCE=yes`
75
- Then the output should contain:
76
- """
77
- Generating test examples *:* in examples/html
78
- --> Rewriting document:title-with-author
79
- --> Generating inline_quoted:emphasis
80
- --> Unchanged quote:with-id-and-role
81
- --> Generating quote:with-title
82
- --> Rewriting quote:with-attribution
83
- --> Unknown quote:basic, doesn't exist in input examples!
84
-
85
- """
86
- And the file "examples/html/quote.html" should contain exactly:
87
- """
88
- <!-- .basic
89
- Doesn't exist in input examples.
90
- -->
91
- <div class="quoteblock">
92
- <blockquote>Four score and seven years ago our fathers brought forth
93
- on this continent a new nation&#8230;&#8203;</blockquote>
94
- </div>
95
-
96
- <!-- .with-id-and-role
97
- Correct example.
98
- -->
99
- <div id="parking"
100
- class="quoteblock startrek">
101
- <blockquote>
102
- Everybody remember
103
- where we parked.
104
- </blockquote>
105
- </div>
106
-
107
- <!-- .with-attribution
108
- Failing example.
109
- -->
110
- <div class="quoteblock">
111
- <blockquote>A person who never made a mistake <em>never</em> tried anything new.</blockquote>
112
- <div class="attribution">— Albert Einstein</div>
113
- </div>
114
-
115
- <!-- .with-title -->
116
- <section class="quoteblock">
117
- <h6>After landing the cloaked Klingon bird of prey in Golden Gate park:</h6>
118
- <blockquote>Everybody remember where we parked.</blockquote>
119
- </section>
120
-
121
- """
122
- And the file "examples/html/document.html" should contain exactly:
123
- """
124
- <!-- .title-with-author
125
- :include: .//body/div[@id="header"]
126
- -->
127
- <div id="header">
128
- <h1>The Dangerous and Thrilling Documentation Chronicles</h1>
129
- <div class="details"><span id="author">Kismet Rainbow Chameleon</span></div>
130
- </div>
131
-
132
- """
133
-
134
- Scenario: Regenerate outdated output examples specified by filter
135
- When I run `bundle exec rake doctest:generate PATTERN="*:*attribution" FORCE=yes`
136
- Then the output should contain:
137
- """
138
- Generating test examples *:*attribution in examples/html
139
- --> Rewriting quote:with-attribution
140
-
141
- """
142
- And the file "examples/html/quote.html" should contain exactly:
143
- """
144
- <!-- .basic
145
- Doesn't exist in input examples.
146
- -->
147
- <div class="quoteblock">
148
- <blockquote>Four score and seven years ago our fathers brought forth
149
- on this continent a new nation&#8230;&#8203;</blockquote>
150
- </div>
151
-
152
- <!-- .with-id-and-role
153
- Correct example.
154
- -->
155
- <div id="parking"
156
- class="quoteblock startrek">
157
- <blockquote>
158
- Everybody remember
159
- where we parked.
160
- </blockquote>
161
- </div>
162
-
163
- <!-- .with-attribution
164
- Failing example.
165
- -->
166
- <div class="quoteblock">
167
- <blockquote>A person who never made a mistake <em>never</em> tried anything new.</blockquote>
168
- <div class="attribution">— Albert Einstein</div>
169
- </div>
170
-
171
- """
@@ -1,5 +0,0 @@
1
- require 'fileutils'
2
-
3
- Given 'I do have a template-based HTML backend with DocTest' do
4
- FileUtils.cp_r Dir.glob("#{FIXTURES_DIR}/html-slim/**"), TEMP_DIR
5
- end
@@ -1,24 +0,0 @@
1
- require 'aruba'
2
- require 'aruba/cucumber'
3
- require 'asciidoctor/doctest'
4
- require 'fileutils'
5
- require 'rspec/expectations'
6
-
7
- Dir["#{__dir__}/../step_definitions/**/*.rb"].each { |file| require file }
8
-
9
- PROJECT_DIR = File.expand_path('../../', __dir__)
10
- FIXTURES_DIR = File.expand_path('../fixtures', __dir__)
11
- TEMP_DIR = File.join(PROJECT_DIR, 'tmp/aruba')
12
-
13
- Before do
14
- FileUtils.mkdir_p TEMP_DIR
15
- # overwrite Aruba's default temp directory location
16
- @dirs = [TEMP_DIR]
17
-
18
- # Increase timeout for JRuby, that is very slooow...
19
- @aruba_timeout_seconds = 50
20
- end
21
-
22
- After do
23
- FileUtils.rm_rf(TEMP_DIR) if Dir.exist? TEMP_DIR
24
- end
@@ -1,98 +0,0 @@
1
- Feature: Testing a custom HTML backend
2
-
3
- Background:
4
- Given I do have a template-based HTML backend with DocTest
5
-
6
- Scenario: Some examples do not match the expected output
7
- When I run `bundle exec rake doctest:test`
8
- Then the output should contain:
9
- """
10
- Running DocTest for the templates: templates.
11
-
12
- FS.SF
13
- """
14
- Then the output should contain:
15
- """
16
- ✗ Failure: quote:with-attribution
17
- Failing example..
18
-
19
- <div class="quoteblock">
20
- <blockquote>A person who never made a mistake <em>never</em> tried anything new.</blockquote>
21
- E <div>Albert Einstein</div>
22
- A <div class="attribution">— Albert Einstein</div>
23
- </div>
24
- """
25
- And the output should contain:
26
- """
27
- ✗ Failure: document:title-with-author
28
- This example should fail..
29
-
30
- <div id="header">
31
- <h1>The Dangerous and Thrilling Documentation Chronicles</h1>
32
- E <div id="author">Kismet Rainbow Chameleon</div>
33
- A <div class="details"><span id="author">Kismet Rainbow Chameleon</span></div>
34
- </div>
35
- """
36
- And the output should contain:
37
- """
38
- 5 examples (1 passed, 2 failed, 2 skipped)
39
- """
40
- And the output should contain:
41
- """
42
- You have skipped tests. Run with VERBOSE=yes for details.
43
- """
44
-
45
- When I run `bundle exec rake doctest:test VERBOSE=yes`
46
- Then the output should contain:
47
- """
48
- Running DocTest for the templates: templates.
49
-
50
- ✗ document:title-with-author
51
- ∅ inline_quoted:emphasis
52
- ✓ quote:with-id-and-role
53
- ∅ quote:with-title
54
- ✗ quote:with-attribution
55
-
56
- """
57
- And the output should contain:
58
- """
59
- ∅ Skipped: quote:with-title
60
- No expected output found
61
- """
62
- And the output should contain:
63
- """
64
- ∅ Skipped: inline_quoted:emphasis
65
- No expected output found
66
- """
67
-
68
- Scenario: Test only examples matching the pattern
69
- When I run `bundle exec rake doctest:test PATTERN=quot*:* VERBOSE=yes`
70
- Then the output should contain:
71
- """
72
- Running DocTest for the templates: templates.
73
-
74
- ✓ quote:with-id-and-role
75
- ∅ quote:with-title
76
- ✗ quote:with-attribution
77
-
78
- """
79
-
80
- Scenario: A necessary template is missing and fallback to the built-in converter is disabled
81
- When I remove the file "templates/inline_quoted.html.slim"
82
- And I run `bundle exec rake doctest:test`
83
- Then the output should contain:
84
- """
85
- Could not find a custom template to handle template_name: inline_quoted
86
- """
87
- And the output should contain:
88
- """
89
- ✗ Failure: quote:with-attribution
90
- Failing example..
91
-
92
- <div class="quoteblock">
93
- E <blockquote>A person who never made a mistake <em>never</em> tried anything new.</blockquote>
94
- E <div>Albert Einstein</div>
95
- A <blockquote>A person who never made a mistake --TEMPLATE NOT FOUND-- tried anything new.</blockquote>
96
- A <div class="attribution">— Albert Einstein</div>
97
- </div>
98
- """
@@ -1,64 +0,0 @@
1
- require 'fileutils'
2
-
3
- describe DocTest::AsciidocConverter do
4
-
5
- subject { described_class }
6
-
7
- it { is_expected.to have_method :convert, :call }
8
-
9
-
10
- describe '#initialize' do
11
-
12
- context 'with defaults' do
13
- subject { described_class.new.opts }
14
- it { is_expected.to include safe: :safe }
15
- end
16
-
17
- context 'with backend_name' do
18
- subject { described_class.new(backend_name: 'html5').opts }
19
- it { is_expected.to include backend: 'html5' }
20
-
21
- context 'empty string' do
22
- subject { described_class.new(backend_name: '').opts }
23
- it { is_expected.to_not include :backend }
24
- end
25
- end
26
-
27
- context 'with template_dirs' do
28
- include FakeFS::SpecHelpers
29
-
30
- subject { described_class.new(template_dirs: template_dirs).opts }
31
- let(:template_dirs) { ['/tmp/html5'] }
32
-
33
- before { FileUtils.mkpath template_dirs[0] }
34
-
35
- context 'that exists' do
36
- it do
37
- is_expected.to include(
38
- template_dirs: template_dirs,
39
- converter: DocTest::NoFallbackTemplateConverter
40
- )
41
- end
42
-
43
- context 'and templates_fallback is true' do
44
- subject { described_class.new(template_dirs: template_dirs, templates_fallback: true).opts }
45
- it { is_expected.to include template_dirs: template_dirs }
46
- it { is_expected.to_not include :converter }
47
- end
48
-
49
- context 'and custom converter' do
50
- subject { described_class.new(template_dirs: template_dirs, converter: converter).opts }
51
- let(:converter) { Asciidoctor::Converter::TemplateConverter }
52
-
53
- it { is_expected.to include template_dirs: template_dirs, converter: converter }
54
- end
55
- end
56
-
57
- context "that doesn't exist" do
58
- let(:template_dirs) { ['/tmp/html5', '/tmp/revealjs'] }
59
-
60
- it { expect { subject }.to raise_error ArgumentError }
61
- end
62
- end
63
- end
64
- end
data/spec/example_spec.rb DELETED
@@ -1,180 +0,0 @@
1
- describe DocTest::Example do
2
-
3
- subject(:o) { described_class.new ['foo', 'bar'] }
4
-
5
- it do
6
- is_expected.to respond_to :group_name, :local_name, :desc, :opts, :content
7
- end
8
-
9
- describe '#name' do
10
-
11
- it 'returns #{group_name}:#{local_name}' do
12
- o.group_name = 'block_olist'
13
- o.local_name = 'with-start'
14
-
15
- expect(o.name).to eq "#{o.group_name}:#{o.local_name}"
16
- end
17
- end
18
-
19
- describe '#name=' do
20
-
21
- shared_examples :example do
22
- it 'sets group_name and local_name' do
23
- is_expected.to have_attributes group_name: 'section', local_name: 'basic'
24
- end
25
- end
26
-
27
- context 'with String' do
28
- before { o.name = 'section:basic' }
29
- include_examples :example
30
- end
31
-
32
- context 'with Array' do
33
- before { o.name = ['section', 'basic'] }
34
- include_examples :example
35
- end
36
- end
37
-
38
- describe '#name_match?' do
39
- name = 'block_ulist:with-title'
40
-
41
- context "when name is e.g. #{name}" do
42
- subject(:o) { described_class.new(name) }
43
-
44
- [ '*', '*:*', 'block_ulist:*', '*:with-title', 'block_*:*',
45
- 'block_ulist:with-*', 'block_ulist:*title'
46
- ].each do |pattern|
47
- it "returns true for #{pattern}" do
48
- expect(o.name_match?(pattern)).to be_truthy
49
- end
50
- end
51
-
52
- [ 'block_foo:with-title', 'block_ulist:foo', 'foo:*' '*:foo', 'foo'
53
- ].each do |pattern|
54
- it "returns false for #{pattern}" do
55
- expect(o.name_match?(pattern)).to be_falsy
56
- end
57
- end
58
- end
59
- end
60
-
61
- describe '#empty?' do
62
- subject { o.empty? }
63
-
64
- context 'when content is nil' do
65
- before { o.content = nil }
66
- it { is_expected.to be_truthy }
67
- end
68
-
69
- context 'when content is blank' do
70
- before { o.content = ' ' }
71
- it { is_expected.to be_truthy }
72
- end
73
-
74
- context 'when content is not blank' do
75
- before { o.content = 'allons-y!' }
76
- it { is_expected.to be_falsy }
77
- end
78
- end
79
-
80
- describe '#[]' do
81
-
82
- context 'when option exists' do
83
- it 'returns the option value' do
84
- o.opts[:foo] = 'bar'
85
- expect(o['foo']).to eq 'bar'
86
- end
87
- end
88
-
89
- context 'when option does not exist' do
90
- it 'returns nil' do
91
- expect(o[:nothing]).to be_nil
92
- end
93
- end
94
- end
95
-
96
- describe '#[]=' do
97
- subject { o.opts }
98
-
99
- context 'with boolean value' do
100
- [true, false].each do |value|
101
- it "associates the option with #{value}" do
102
- o['foo'] = value
103
- is_expected.to eq(foo: value)
104
- end
105
- end
106
- end
107
-
108
- context 'with Array value' do
109
- it 'associates the option with the value' do
110
- o['foo'] = ['a', 'b']
111
- is_expected.to eq(foo: ['a', 'b'])
112
- end
113
- end
114
-
115
- context 'with String value' do
116
-
117
- context 'when option is not defined' do
118
- it 'associates the option with the value wrapped in an array' do
119
- o['key'] = 'foo'
120
- is_expected.to eq(key: ['foo'])
121
- end
122
- end
123
-
124
- context 'when option is already defined' do
125
- before { o.opts[:key] = ['foo'] }
126
-
127
- it 'adds the value to array associated with the option' do
128
- o[:key] = 'bar'
129
- is_expected.to eq(key: ['foo', 'bar'])
130
- end
131
- end
132
- end
133
-
134
- context 'with nil value' do
135
- before { o.opts[:key] = ['foo'] }
136
-
137
- it 'deletes the option' do
138
- o[:key] = nil
139
- is_expected.to be_empty
140
- end
141
- end
142
- end
143
-
144
- describe '#==' do
145
-
146
- let(:first) { described_class.new('a:b', content: 'allons-y!') }
147
- let(:second) { described_class.new('a:b', content: 'allons-y!') }
148
-
149
- it 'returns true for different instances with the same name and content' do
150
- expect(first).to eq second
151
- end
152
-
153
- it 'returns false for instances with different name' do
154
- second.name = 'a:x'
155
- expect(first).to_not eq second
156
- end
157
-
158
- it 'returns false for instances with different content' do
159
- expect(second).to receive(:content).and_return('ALLONS-Y!')
160
- expect(first).to_not eq second
161
- end
162
- end
163
-
164
- describe '#dup' do
165
- using Corefines::Object::instance_values
166
-
167
- it 'returns deep copy' do
168
- origo = described_class.new('a:b', content: 'allons-y!', desc: 'who?', opts: {key: ['value']})
169
- copy = origo.dup
170
-
171
- expect(origo).to eql copy
172
- expect(origo).to_not equal copy
173
-
174
- origo.instance_values.values.zip(copy.instance_values.values).each do |val1, val2|
175
- expect(val1).to_not equal val2 unless val1.nil? && val2.nil?
176
- end
177
- expect(origo.opts[:key].first).to_not equal copy.opts[:key].first
178
- end
179
- end
180
- end