Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compiler stack #1000

Merged
merged 6 commits into from Nov 24, 2016
Merged
Diff settings

Always

Just for now

Test #compile_reps

  • Loading branch information...
ddfreyne committed Nov 24, 2016
commit 3036e924d5e4fbefad6802e3ac643640d807aab1
@@ -66,6 +66,50 @@
allow(action_provider).to receive(:memory_for).with(other_rep).and_return(memory)
end

describe '#compile_reps' do
subject { compiler.send(:compile_reps) }

before do
allow(action_provider).to receive(:snapshots_defs_for).with(rep).and_return(snapshot_defs_for_rep)
allow(action_provider).to receive(:snapshots_defs_for).with(other_rep).and_return(snapshot_defs_for_rep)
end

let(:snapshot_defs_for_rep) do
[Nanoc::Int::SnapshotDef.new(:last, true)]
end

let(:snapshot_defs_for_other_rep) do
[Nanoc::Int::SnapshotDef.new(:last, true)]
end

it 'compiles individual reps' do
expect { subject }.to change { rep.snapshot_contents[:last].string }
.from('<%= 1 + 2 %>')
.to('3')
end

context 'exception' do
let(:item) { Nanoc::Int::Item.new('<%= raise "lol" %>', {}, '/hi.md') }

it 'wraps exception' do
expect { subject }.to raise_error(Nanoc::Int::Errors::CompilationError)
end

it 'contains the right item rep in the wrapped exception' do
expect { subject }.to raise_error do |err|
expect(err.item_rep).to eql(rep)
end
end

it 'contains the right wrapped exception' do
expect { subject }.to raise_error do |err|
expect(err.unwrap).to be_a(RuntimeError)
expect(err.unwrap.message).to eq('lol')
end
end
end
end

describe '#compile_rep' do
subject { compiler.send(:compile_rep, rep) }

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.