aboutsummaryrefslogtreecommitdiff
path: root/spec/unit/renderer/read_template_path_spec.rb
diff options
context:
space:
mode:
authorGibheer <gibheer@gmail.com>2012-11-22 07:32:17 +0100
committerGibheer <gibheer@gmail.com>2012-11-26 21:41:09 +0100
commit9e062519bae4fa85ef10c942be5e0e07b23aba50 (patch)
tree3d97bf4172ca8c38aa6bbaf45504ebe519907fec /spec/unit/renderer/read_template_path_spec.rb
parent37a4a28deec224f7cd9a5a124e22258e868913e4 (diff)
first commit for the new renderer
This part handles the building of the template tree, which then gets used later by the containers.
Diffstat (limited to 'spec/unit/renderer/read_template_path_spec.rb')
-rw-r--r--spec/unit/renderer/read_template_path_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/renderer/read_template_path_spec.rb b/spec/unit/renderer/read_template_path_spec.rb
new file mode 100644
index 0000000..8522007
--- /dev/null
+++ b/spec/unit/renderer/read_template_path_spec.rb
@@ -0,0 +1,42 @@
+require 'spec_helper'
+
+describe Zero::Renderer, 'read_template_path!' do
+ subject { Zero::Renderer.new(template_path, type_map) }
+ let(:template_path) { 'foo' }
+ let(:file_list) { ['./foo/welcome/index.html.erb'] }
+
+ before :each do
+ subject.stub(:search_files).and_return(file_list)
+ 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'
+ end
+end