Skip to content

Commit

Permalink
Use post-compile views for checks
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Mar 20, 2017
1 parent 90964f5 commit 548faa7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/nanoc/base/views/post_compile_item_rep_view.rb
Expand Up @@ -16,5 +16,9 @@ def compiled_content(snapshot: nil)

content.string
end

def raw_path(snapshot: :last)
@item_rep.raw_path(snapshot: snapshot)
end
end
end
2 changes: 1 addition & 1 deletion lib/nanoc/checking/check.rb
Expand Up @@ -23,7 +23,7 @@ def self.create(site)
view_context = site.compiler.compilation_context.create_view_context(Nanoc::Int::DependencyTracker::Null.new)

context = {
items: Nanoc::ItemCollectionWithRepsView.new(site.items, view_context),
items: Nanoc::PostCompileItemCollectionView.new(site.items, view_context),
layouts: Nanoc::LayoutCollectionView.new(site.layouts, view_context),
config: Nanoc::ConfigView.new(site.config, view_context),
output_filenames: output_filenames,
Expand Down
58 changes: 58 additions & 0 deletions spec/nanoc/base/views/post_compile_item_rep_view_spec.rb
Expand Up @@ -34,6 +34,64 @@
end
end

describe '#raw_path' do
context 'no args' do
subject { view.raw_path }

it 'does not raise' do
subject
end

context 'no path specified' do
it { is_expected.to be_nil }
end

context 'path for default snapshot specified' do
before do
item_rep.raw_paths = { last: ['output/about/index.html'] }
end

it { is_expected.to eql('output/about/index.html') }
end

context 'path specified, but not for default snapshot' do
before do
item_rep.raw_paths = { pre: ['output/about/index.html'] }
end

it { is_expected.to be_nil }
end
end

context 'snapshot arg' do
subject { view.raw_path(snapshot: :special) }

it 'does not raise' do
subject
end

context 'no path specified' do
it { is_expected.to be_nil }
end

context 'path for default snapshot specified' do
before do
item_rep.raw_paths = { special: ['output/about/index.html'] }
end

it { is_expected.to eql('output/about/index.html') }
end

context 'path specified, but not for default snapshot' do
before do
item_rep.raw_paths = { pre: ['output/about/index.html'] }
end

it { is_expected.to be_nil }
end
end
end

describe '#compiled_content' do
subject { view.compiled_content }

Expand Down

0 comments on commit 548faa7

Please sign in to comment.