cleanup old specs
This commit is contained in:
parent
f18ab69a91
commit
a6fa1475a2
|
@ -2,65 +2,15 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Zero::Renderer, '#read_template_path!' do
|
describe Zero::Renderer, '#read_template_path!' do
|
||||||
subject { Zero::Renderer.new(template_path, type_map) }
|
subject { Zero::Renderer.new(template_path, type_map) }
|
||||||
let(:template_path) { 'foo/' }
|
let(:template_path) { 'spec/fixtures/templates/' }
|
||||||
let(:file_list) { ['foo/welcome/index.html.erb'] }
|
let(:type_map) { {'html' => ['text/html']} }
|
||||||
|
let(:result) { {
|
||||||
before :each do
|
'text/html' => template_path + 'index.html.erb',
|
||||||
Dir.stub(:[]) do |arg|
|
'json' => template_path + 'index.json.erb'
|
||||||
if arg == 'foo/**/*.*'
|
|
||||||
file_list
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
shared_examples_for 'a template loader' do
|
|
||||||
it 'creates a template tree' do
|
|
||||||
subject.read_template_path!
|
|
||||||
subject.templates['welcome/index'].should eq(result)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'without mapping' do
|
|
||||||
let(:type_map) { {} }
|
|
||||||
let(:result) { { 'html' => 'foo/welcome/index.html.erb' } }
|
|
||||||
|
|
||||||
it_behaves_like 'a template loader'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with a single mapping' do
|
|
||||||
let(:type_map) { {'html' => 'text/html' } }
|
|
||||||
let(:result) { { 'text/html' => 'foo/welcome/index.html.erb' } }
|
|
||||||
|
|
||||||
it_behaves_like 'a template loader'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with multiple mappings' do
|
|
||||||
let(:type_map) { {'html' => ['text/html', 'text/xml'] } }
|
|
||||||
let(:result) { {
|
|
||||||
'text/html' => 'foo/welcome/index.html.erb',
|
|
||||||
'text/xml' => 'foo/welcome/index.html.erb'
|
|
||||||
} }
|
} }
|
||||||
|
|
||||||
it_behaves_like 'a template loader'
|
it "loads the templates" do
|
||||||
end
|
|
||||||
|
|
||||||
context 'with default template' do
|
|
||||||
let(:file_list) {['foo/welcome/index.erb']}
|
|
||||||
let(:type_map) { {'default' => ['text/html', 'text/xml'] } }
|
|
||||||
let(:result) { {
|
|
||||||
'text/html' => 'foo/welcome/index.erb',
|
|
||||||
'text/xml' => 'foo/welcome/index.erb'
|
|
||||||
} }
|
|
||||||
|
|
||||||
it_behaves_like 'a template loader'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates an empty templates list without templates in path' do
|
|
||||||
subject = Zero::Renderer.new("bar/", {})
|
|
||||||
subject.read_template_path!
|
subject.read_template_path!
|
||||||
|
expect(subject.templates['index']).to eq(result)
|
||||||
subject.templates.should eq({})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue