producer-core/spec/producer/core/template_spec.rb
2014-10-10 16:36:06 +00:00

34 lines
907 B
Ruby

require 'spec_helper'
module Producer::Core
describe Template do
include FixturesHelpers
let(:path) { 'basic' }
let(:search_path) { fixture_path_for 'templates' }
subject(:template) { described_class.new path, search_path: search_path }
describe '#render' do
it 'renders ERB templates' do
expect(template.render).to eq "basic template\n"
end
context 'when variables are given' do
let(:path) { 'variables' }
it 'declares given variables in ERB render binding' do
expect(template.render foo: 'bar').to eq "bar\n"
end
end
context 'when relative path is requested' do
let(:path) { fixture_path_for('templates/basic').insert 0, './' }
it 'does not enforce `template\' search path' do
expect(template.render).to eq "basic template\n"
end
end
end
end
end