nanoc 4.8.11 → 4.8.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/NEWS.md +10 -0
- data/README.md +1 -0
- data/lib/nanoc/base/entities/pattern.rb +2 -0
- data/lib/nanoc/base/entities/site.rb +1 -1
- data/lib/nanoc/base/repos/action_sequence_store.rb +4 -1
- data/lib/nanoc/base/repos/compiled_content_cache.rb +2 -2
- data/lib/nanoc/base/services/compiler.rb +4 -1
- data/lib/nanoc/base/services/compiler/stages/cleanup.rb +3 -3
- data/lib/nanoc/filters/colorize_syntax/colorizers.rb +2 -3
- data/lib/nanoc/filters/pandoc.rb +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/nanoc.manifest +4 -6
- data/spec/gem_spec.rb +21 -0
- data/spec/manifest_spec.rb +2 -2
- data/spec/nanoc/base/compiler_spec.rb +7 -2
- data/spec/nanoc/base/entities/pattern_spec.rb +6 -0
- data/spec/nanoc/base/repos/compiled_content_cache_spec.rb +9 -1
- data/spec/nanoc/base/repos/dependency_store_spec.rb +116 -9
- data/spec/nanoc/base/repos/store_spec.rb +34 -0
- data/spec/nanoc/base/services/compiler/phases/cache_spec.rb +9 -1
- data/spec/nanoc/base/services/compiler/stages/cleanup_spec.rb +1 -1
- data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +1 -1
- data/spec/nanoc/base/services/notification_center_spec.rb +25 -0
- data/spec/nanoc/base/services/outdatedness_checker_spec.rb +3 -3
- data/spec/nanoc/base/services/outdatedness_rules_spec.rb +2 -2
- data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +10 -2
- data/spec/nanoc/filters/colorize_syntax/rouge_spec.rb +66 -108
- data/spec/nanoc/regressions/gh_1248_spec.rb +24 -0
- data/spec/nanoc/rule_dsl/rule_spec.rb +111 -0
- data/spec/spec_helper.rb +0 -6
- data/test/base/test_compiler.rb +0 -54
- data/test/filters/test_pandoc.rb +2 -2
- data/test/helper.rb +0 -36
- metadata +7 -9
- data/Appraisals +0 -13
- data/test/base/test_dependency_tracker.rb +0 -265
- data/test/base/test_notification_center.rb +0 -32
- data/test/base/test_store.rb +0 -39
- data/test/rule_dsl/test_rule.rb +0 -27
- data/test/test_gem.rb +0 -30
@@ -56,4 +56,38 @@ describe Nanoc::Int::Store do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
|
+
|
60
|
+
let(:test_store_klass) do
|
61
|
+
Class.new(Nanoc::Int::Store) do
|
62
|
+
def data
|
63
|
+
@data
|
64
|
+
end
|
65
|
+
|
66
|
+
def data=(new_data)
|
67
|
+
@data = new_data
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'deletes and reloads on error' do
|
73
|
+
store = test_store_klass.new('test.db', 1)
|
74
|
+
|
75
|
+
# Create
|
76
|
+
store.load
|
77
|
+
store.data = { fun: 'sure' }
|
78
|
+
store.store
|
79
|
+
|
80
|
+
# Test stored values
|
81
|
+
store = test_store_klass.new('test.db', 1)
|
82
|
+
store.load
|
83
|
+
expect(store.data).to eq(fun: 'sure')
|
84
|
+
|
85
|
+
# Mess up
|
86
|
+
File.write('test.db', 'Damn {}#}%@}$^)@&$&*^#@ broken stores!!!')
|
87
|
+
|
88
|
+
# Reload
|
89
|
+
store = test_store_klass.new('test.db', 1)
|
90
|
+
store.load
|
91
|
+
expect(store.data).to be_nil
|
92
|
+
end
|
59
93
|
end
|
@@ -10,7 +10,7 @@ describe Nanoc::Int::Compiler::Phases::Cache do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:compiled_content_cache) do
|
13
|
-
Nanoc::Int::CompiledContentCache.new(items: [item])
|
13
|
+
Nanoc::Int::CompiledContentCache.new(items: [item], site: site)
|
14
14
|
end
|
15
15
|
|
16
16
|
let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
|
@@ -32,6 +32,14 @@ describe Nanoc::Int::Compiler::Phases::Cache do
|
|
32
32
|
let(:item) { Nanoc::Int::Item.new('item content', {}, '/donkey.md') }
|
33
33
|
let(:rep) { Nanoc::Int::ItemRep.new(item, :latex) }
|
34
34
|
|
35
|
+
let(:site) do
|
36
|
+
Nanoc::Int::Site.new(
|
37
|
+
config: Nanoc::Int::Configuration.new.with_defaults,
|
38
|
+
code_snippets: [],
|
39
|
+
data_source: Nanoc::Int::InMemDataSource.new([item], []),
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
35
43
|
describe '#run' do
|
36
44
|
subject { phase.call(rep, is_outdated: is_outdated) }
|
37
45
|
|
@@ -25,7 +25,7 @@ describe Nanoc::Int::Compiler::Stages::CompileReps do
|
|
25
25
|
let(:action_provider) { double(:action_provider) }
|
26
26
|
let(:action_sequences) { double(:action_sequences) }
|
27
27
|
let(:reps) { Nanoc::Int::ItemRepRepo.new }
|
28
|
-
let(:compiled_content_cache) { Nanoc::Int::CompiledContentCache.new(items: items) }
|
28
|
+
let(:compiled_content_cache) { Nanoc::Int::CompiledContentCache.new(items: items, site: site) }
|
29
29
|
let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
|
30
30
|
|
31
31
|
let(:outdatedness_store) { Nanoc::Int::OutdatednessStore.new(site: site) }
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Nanoc::Int::NotificationCenter do
|
4
|
+
it 'receives notification after subscribing' do
|
5
|
+
ping_received = false
|
6
|
+
Nanoc::Int::NotificationCenter.on :ping_received, :test do
|
7
|
+
ping_received = true
|
8
|
+
end
|
9
|
+
|
10
|
+
Nanoc::Int::NotificationCenter.post :ping_received
|
11
|
+
expect(ping_received).to be
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'does not receive notification after unsubscribing' do
|
15
|
+
ping_received = false
|
16
|
+
Nanoc::Int::NotificationCenter.on :ping_received, :test do
|
17
|
+
ping_received = true
|
18
|
+
end
|
19
|
+
|
20
|
+
Nanoc::Int::NotificationCenter.remove :ping_received, :test
|
21
|
+
|
22
|
+
Nanoc::Int::NotificationCenter.post :ping_received
|
23
|
+
expect(ping_received).not_to be
|
24
|
+
end
|
25
|
+
end
|
@@ -42,7 +42,7 @@ describe Nanoc::Int::OutdatednessChecker do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
let(:action_sequence_store) do
|
45
|
-
Nanoc::Int::ActionSequenceStore.new
|
45
|
+
Nanoc::Int::ActionSequenceStore.new(site: site)
|
46
46
|
end
|
47
47
|
|
48
48
|
let(:old_action_sequence_for_item_rep) do
|
@@ -74,7 +74,7 @@ describe Nanoc::Int::OutdatednessChecker do
|
|
74
74
|
|
75
75
|
let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: items.to_a + layouts.to_a) }
|
76
76
|
|
77
|
-
let(:config) { Nanoc::Int::Configuration.new }
|
77
|
+
let(:config) { Nanoc::Int::Configuration.new.with_defaults }
|
78
78
|
|
79
79
|
before do
|
80
80
|
checksum_store.add(item)
|
@@ -182,7 +182,7 @@ describe Nanoc::Int::OutdatednessChecker do
|
|
182
182
|
let(:other_item) { Nanoc::Int::Item.new('other stuff', {}, '/other.md') }
|
183
183
|
let(:other_item_rep) { Nanoc::Int::ItemRep.new(other_item, :default) }
|
184
184
|
|
185
|
-
let(:config) { Nanoc::Int::Configuration.new }
|
185
|
+
let(:config) { Nanoc::Int::Configuration.new.with_defaults }
|
186
186
|
|
187
187
|
let(:items) { Nanoc::Int::ItemCollection.new(config, [item, other_item]) }
|
188
188
|
|
@@ -21,7 +21,7 @@ describe Nanoc::Int::OutdatednessRules do
|
|
21
21
|
let(:item_rep) { Nanoc::Int::ItemRep.new(item, :default) }
|
22
22
|
let(:item) { Nanoc::Int::Item.new('stuff', {}, '/foo.md') }
|
23
23
|
|
24
|
-
let(:config) { Nanoc::Int::Configuration.new }
|
24
|
+
let(:config) { Nanoc::Int::Configuration.new.with_defaults }
|
25
25
|
let(:code_snippets) { [] }
|
26
26
|
let(:objects) { [config] + code_snippets + [item] }
|
27
27
|
|
@@ -36,7 +36,7 @@ describe Nanoc::Int::OutdatednessRules do
|
|
36
36
|
let(:action_sequences) { {} }
|
37
37
|
let(:reps) { Nanoc::Int::ItemRepRepo.new }
|
38
38
|
let(:dependency_store) { Nanoc::Int::DependencyStore.new(items, layouts, config) }
|
39
|
-
let(:action_sequence_store) { Nanoc::Int::ActionSequenceStore.new }
|
39
|
+
let(:action_sequence_store) { Nanoc::Int::ActionSequenceStore.new(site: site) }
|
40
40
|
let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }
|
41
41
|
|
42
42
|
let(:checksums) do
|
@@ -23,7 +23,7 @@ describe Nanoc::PostCompileItemRepView do
|
|
23
23
|
|
24
24
|
let(:reps) { double(:reps) }
|
25
25
|
let(:items) { Nanoc::Int::ItemCollection.new(config) }
|
26
|
-
let(:config) { Nanoc::Int::Configuration.new }
|
26
|
+
let(:config) { Nanoc::Int::Configuration.new.with_defaults }
|
27
27
|
let(:dependency_tracker) { Nanoc::Int::DependencyTracker.new(double(:dependency_store)) }
|
28
28
|
let(:compilation_context) { double(:compilation_context, compiled_content_cache: compiled_content_cache) }
|
29
29
|
let(:snapshot_repo) { double(:snapshot_repo) }
|
@@ -36,8 +36,16 @@ describe Nanoc::PostCompileItemRepView do
|
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
+
let(:site) do
|
40
|
+
Nanoc::Int::Site.new(
|
41
|
+
config: config,
|
42
|
+
code_snippets: [],
|
43
|
+
data_source: Nanoc::Int::InMemDataSource.new(items, []),
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
39
47
|
let(:compiled_content_cache) do
|
40
|
-
Nanoc::Int::CompiledContentCache.new(items: items).tap do |ccc|
|
48
|
+
Nanoc::Int::CompiledContentCache.new(items: items, site: site).tap do |ccc|
|
41
49
|
ccc[item_rep] = snapshot_contents
|
42
50
|
end
|
43
51
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rouge'
|
4
4
|
|
5
|
-
describe Nanoc::Filters::ColorizeSyntax, filter: true
|
5
|
+
describe Nanoc::Filters::ColorizeSyntax, filter: true do
|
6
6
|
subject { filter.setup_and_run(input, default_colorizer: :rouge, rouge: params) }
|
7
7
|
let(:filter) { ::Nanoc::Filters::ColorizeSyntax.new }
|
8
8
|
let(:params) { {} }
|
@@ -28,10 +28,15 @@ describe Nanoc::Filters::ColorizeSyntax, filter: true, rouge: true do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'with Rouge' do
|
31
|
-
context 'with
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
context 'with default options' do
|
32
|
+
it { is_expected.to eql output }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with legacy' do
|
36
|
+
let(:legacy) { true }
|
37
|
+
let(:params) { super().merge(legacy: legacy) }
|
38
|
+
|
39
|
+
it { is_expected.to eql output }
|
35
40
|
|
36
41
|
context 'with pygments wrapper' do
|
37
42
|
let(:wrap) { true }
|
@@ -53,12 +58,12 @@ describe Nanoc::Filters::ColorizeSyntax, filter: true, rouge: true do
|
|
53
58
|
let(:output) do
|
54
59
|
<<~EOS
|
55
60
|
before
|
56
|
-
<pre><code class="language-ruby"><table
|
57
|
-
<td class="gutter gl"
|
58
|
-
2
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
<pre><code class="language-ruby"><table class="rouge-table"><tbody><tr>
|
62
|
+
<td class="rouge-gutter gl"><pre class="lineno">1
|
63
|
+
2
|
64
|
+
</pre></td>
|
65
|
+
<td class="rouge-code"><pre> <span class="k">def</span> <span class="nf">foo</span>
|
66
|
+
<span class="k">end</span></pre></td>
|
62
67
|
</tr></tbody></table></code></pre>
|
63
68
|
after
|
64
69
|
EOS
|
@@ -68,129 +73,82 @@ describe Nanoc::Filters::ColorizeSyntax, filter: true, rouge: true do
|
|
68
73
|
end
|
69
74
|
end
|
70
75
|
|
71
|
-
context 'with
|
72
|
-
|
73
|
-
it { is_expected.to eql output }
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'with legacy' do
|
77
|
-
let(:legacy) { true }
|
78
|
-
let(:params) { super().merge(legacy: legacy) }
|
79
|
-
|
80
|
-
it { is_expected.to eql output }
|
81
|
-
|
82
|
-
context 'with pygments wrapper' do
|
83
|
-
let(:wrap) { true }
|
84
|
-
let(:params) { super().merge(wrap: wrap) }
|
85
|
-
|
86
|
-
it { is_expected.to eql output }
|
87
|
-
|
88
|
-
context 'with css_class' do
|
89
|
-
let(:css_class) { 'nanoc' }
|
90
|
-
let(:params) { super().merge(css_class: css_class) }
|
76
|
+
context 'with formater' do
|
77
|
+
let(:params) { super().merge(formatter: formatter) }
|
91
78
|
|
92
|
-
|
93
|
-
|
94
|
-
end
|
79
|
+
context 'with inline' do
|
80
|
+
let(:formatter) { Rouge::Formatters::HTMLInline.new(theme) }
|
95
81
|
|
96
|
-
context 'with
|
97
|
-
let(:
|
98
|
-
let(:params) { super().merge(line_numbers: line_numbers) }
|
82
|
+
context 'with github theme' do
|
83
|
+
let(:theme) { Rouge::Themes::Github.new }
|
99
84
|
let(:output) do
|
100
85
|
<<~EOS
|
101
86
|
before
|
102
|
-
<pre><code class="language-ruby"
|
103
|
-
|
104
|
-
2
|
105
|
-
</pre></td>
|
106
|
-
<td class="rouge-code"><pre> <span class="k">def</span> <span class="nf">foo</span>
|
107
|
-
<span class="k">end</span></pre></td>
|
108
|
-
</tr></tbody></table></code></pre>
|
87
|
+
<pre><code class="language-ruby"> <span style="color: #000000;font-weight: bold">def</span> <span style="color: #990000;font-weight: bold">foo</span>
|
88
|
+
<span style="color: #000000;font-weight: bold">end</span></code></pre>
|
109
89
|
after
|
110
90
|
EOS
|
111
91
|
end
|
112
92
|
|
113
93
|
it { is_expected.to eql output }
|
114
94
|
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'with formater' do
|
118
|
-
let(:params) { super().merge(formatter: formatter) }
|
119
|
-
|
120
|
-
context 'with inline' do
|
121
|
-
let(:formatter) { Rouge::Formatters::HTMLInline.new(theme) }
|
122
|
-
|
123
|
-
context 'with github theme' do
|
124
|
-
let(:theme) { Rouge::Themes::Github.new }
|
125
|
-
let(:output) do
|
126
|
-
<<~EOS
|
127
|
-
before
|
128
|
-
<pre><code class="language-ruby"> <span style="color: #000000;font-weight: bold">def</span> <span style="color: #990000;font-weight: bold">foo</span>
|
129
|
-
<span style="color: #000000;font-weight: bold">end</span></code></pre>
|
130
|
-
after
|
131
|
-
EOS
|
132
|
-
end
|
133
|
-
|
134
|
-
it { is_expected.to eql output }
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'with colorful theme' do
|
138
|
-
let(:theme) { Rouge::Themes::Colorful.new }
|
139
|
-
let(:output) do
|
140
|
-
<<~EOS
|
141
|
-
before
|
142
|
-
<pre><code class="language-ruby"> <span style="color: #080;font-weight: bold">def</span> <span style="color: #06B;font-weight: bold">foo</span>
|
143
|
-
<span style="color: #080;font-weight: bold">end</span></code></pre>
|
144
|
-
after
|
145
|
-
EOS
|
146
|
-
end
|
147
|
-
|
148
|
-
it { is_expected.to eql output }
|
149
|
-
end
|
150
|
-
end
|
151
95
|
|
152
|
-
context 'with
|
153
|
-
let(:
|
96
|
+
context 'with colorful theme' do
|
97
|
+
let(:theme) { Rouge::Themes::Colorful.new }
|
154
98
|
let(:output) do
|
155
99
|
<<~EOS
|
156
100
|
before
|
157
|
-
<pre><code class="language-ruby"
|
158
|
-
|
159
|
-
<div class="line-2"> <span class="k">end</span>
|
160
|
-
</div></code></pre>
|
101
|
+
<pre><code class="language-ruby"> <span style="color: #080;font-weight: bold">def</span> <span style="color: #06B;font-weight: bold">foo</span>
|
102
|
+
<span style="color: #080;font-weight: bold">end</span></code></pre>
|
161
103
|
after
|
162
104
|
EOS
|
163
105
|
end
|
164
106
|
|
165
107
|
it { is_expected.to eql output }
|
166
108
|
end
|
109
|
+
end
|
167
110
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
111
|
+
context 'with linewise' do
|
112
|
+
let(:formatter) { Rouge::Formatters::HTMLLinewise.new(Rouge::Formatters::HTML.new) }
|
113
|
+
let(:output) do
|
114
|
+
<<~EOS
|
115
|
+
before
|
116
|
+
<pre><code class="language-ruby"><div class="line-1"> <span class="k">def</span> <span class="nf">foo</span>
|
117
|
+
</div>
|
118
|
+
<div class="line-2"> <span class="k">end</span>
|
119
|
+
</div></code></pre>
|
120
|
+
after
|
121
|
+
EOS
|
174
122
|
end
|
175
123
|
|
176
|
-
|
177
|
-
|
178
|
-
let(:output) do
|
179
|
-
<<~EOS
|
180
|
-
before
|
181
|
-
<pre><code class="language-ruby"><table class="rouge-table"><tbody><tr>
|
182
|
-
<td class="rouge-gutter gl"><pre class="lineno">1
|
183
|
-
2
|
184
|
-
</pre></td>
|
185
|
-
<td class="rouge-code"><pre> <span class="k">def</span> <span class="nf">foo</span>
|
186
|
-
<span class="k">end</span></pre></td>
|
187
|
-
</tr></tbody></table></code></pre>
|
188
|
-
after
|
189
|
-
EOS
|
190
|
-
end
|
124
|
+
it { is_expected.to eql output }
|
125
|
+
end
|
191
126
|
|
192
|
-
|
127
|
+
context 'with pygments' do
|
128
|
+
let(:wrap) { true }
|
129
|
+
let(:css_class) { 'codehilite' }
|
130
|
+
let(:formatter) { Rouge::Formatters::HTMLPygments.new(Rouge::Formatters::HTML.new) }
|
131
|
+
|
132
|
+
it { is_expected.to eql output }
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'with table' do
|
136
|
+
let(:formatter) { Rouge::Formatters::HTMLTable.new(Rouge::Formatters::HTML.new) }
|
137
|
+
let(:output) do
|
138
|
+
<<~EOS
|
139
|
+
before
|
140
|
+
<pre><code class="language-ruby"><table class="rouge-table"><tbody><tr>
|
141
|
+
<td class="rouge-gutter gl"><pre class="lineno">1
|
142
|
+
2
|
143
|
+
</pre></td>
|
144
|
+
<td class="rouge-code"><pre> <span class="k">def</span> <span class="nf">foo</span>
|
145
|
+
<span class="k">end</span></pre></td>
|
146
|
+
</tr></tbody></table></code></pre>
|
147
|
+
after
|
148
|
+
EOS
|
193
149
|
end
|
150
|
+
|
151
|
+
it { is_expected.to eql output }
|
194
152
|
end
|
195
153
|
end
|
196
154
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'GH-1248', site: true, stdio: true do
|
4
|
+
before do
|
5
|
+
File.write('content/stuff.html', 'hi')
|
6
|
+
|
7
|
+
File.write('Rules', <<~EOS)
|
8
|
+
preprocess do
|
9
|
+
@config[:output_dir] = 'ootpoot'
|
10
|
+
end
|
11
|
+
|
12
|
+
passthrough '/**/*'
|
13
|
+
EOS
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
Nanoc::CLI.run(%w[compile])
|
18
|
+
end
|
19
|
+
|
20
|
+
example do
|
21
|
+
expect { Nanoc::CLI.run(%w[compile --verbose]) }
|
22
|
+
.not_to output(/identical .* ootpoot\/stuff.html/).to_stdout
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Nanoc::RuleDSL::Rule do
|
4
|
+
subject(:rule) do
|
5
|
+
Nanoc::RuleDSL::Rule.new(pattern, :xml, block)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:pattern) { Nanoc::Int::Pattern.from(%r{/(.*)/(.*)/}) }
|
9
|
+
let(:block) { proc {} }
|
10
|
+
|
11
|
+
describe '#matches' do
|
12
|
+
subject { rule.send(:matches, identifier) }
|
13
|
+
|
14
|
+
context 'does not match' do
|
15
|
+
let(:identifier) { '/moo/' }
|
16
|
+
it { is_expected.to be_nil }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'matches' do
|
20
|
+
let(:identifier) { '/anything/else/' }
|
21
|
+
it { is_expected.to eql(%w[anything else]) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#initialize' do
|
26
|
+
context 'with snapshot_name' do
|
27
|
+
subject { Nanoc::RuleDSL::Rule.new(pattern, :xml, proc {}, snapshot_name: :donkey) }
|
28
|
+
|
29
|
+
its(:rep_name) { is_expected.to eql(:xml) }
|
30
|
+
its(:pattern) { is_expected.to eql(pattern) }
|
31
|
+
its(:snapshot_name) { is_expected.to eql(:donkey) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'without snapshot_name' do
|
35
|
+
subject { Nanoc::RuleDSL::Rule.new(pattern, :xml, proc {}) }
|
36
|
+
|
37
|
+
its(:rep_name) { is_expected.to eql(:xml) }
|
38
|
+
its(:pattern) { is_expected.to eql(pattern) }
|
39
|
+
its(:snapshot_name) { is_expected.to be_nil }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#applicable_to?' do
|
44
|
+
subject { rule.applicable_to?(item) }
|
45
|
+
|
46
|
+
let(:item) { Nanoc::Int::Item.new('', {}, '/foo.md') }
|
47
|
+
|
48
|
+
context 'pattern matches' do
|
49
|
+
let(:pattern) { Nanoc::Int::Pattern.from(%r{^/foo.*}) }
|
50
|
+
it { is_expected.to be }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'pattern does not match' do
|
54
|
+
let(:pattern) { Nanoc::Int::Pattern.from(%r{^/bar.*}) }
|
55
|
+
it { is_expected.not_to be }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#apply_to' do
|
60
|
+
subject { rule.apply_to(rep, site: site, executor: executor, view_context: view_context) }
|
61
|
+
|
62
|
+
let(:block) do
|
63
|
+
proc { self }
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:item) { Nanoc::Int::Item.new('', {}, '/foo.md') }
|
67
|
+
let(:rep) { Nanoc::Int::ItemRep.new(item, :amazings) }
|
68
|
+
|
69
|
+
let(:site) { Nanoc::Int::Site.new(config: config, data_source: data_source, code_snippets: []) }
|
70
|
+
let(:data_source) { Nanoc::Int::InMemDataSource.new(items, layouts) }
|
71
|
+
let(:config) { Nanoc::Int::Configuration.new }
|
72
|
+
let(:executor) { nil }
|
73
|
+
let(:view_context) { Nanoc::ViewContextForPreCompilation.new(items: items) }
|
74
|
+
let(:items) { Nanoc::Int::ItemCollection.new(config, []) }
|
75
|
+
let(:layouts) { Nanoc::Int::LayoutCollection.new(config, []) }
|
76
|
+
|
77
|
+
it 'returns a rule context' do
|
78
|
+
expect(subject).to be_a(Nanoc::RuleDSL::RuleContext)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'makes rep accessible' do
|
82
|
+
expect(subject.instance_eval { rep }.unwrap).to eql(rep)
|
83
|
+
expect(subject.instance_eval { @rep }.unwrap).to eql(rep)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'makes item_rep accessible' do
|
87
|
+
expect(subject.instance_eval { item_rep }.unwrap).to eql(rep)
|
88
|
+
expect(subject.instance_eval { @item_rep }.unwrap).to eql(rep)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'makes item accessible' do
|
92
|
+
expect(subject.instance_eval { item }.unwrap).to eql(item)
|
93
|
+
expect(subject.instance_eval { @item }.unwrap).to eql(item)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'makes items accessible' do
|
97
|
+
expect(subject.instance_eval { items }.unwrap).to eql(items)
|
98
|
+
expect(subject.instance_eval { @items }.unwrap).to eql(items)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'makes layouts accessible' do
|
102
|
+
expect(subject.instance_eval { layouts }.unwrap).to eql(layouts)
|
103
|
+
expect(subject.instance_eval { @layouts }.unwrap).to eql(layouts)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'makes config accessible' do
|
107
|
+
expect(subject.instance_eval { config }.unwrap).to eql(config)
|
108
|
+
expect(subject.instance_eval { @config }.unwrap).to eql(config)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|