Sha256: 1d978c99102a0d29e8c618bfe620081d5620a5137501d8b742884203b1f85c3c

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

# encoding: UTF-8
require 'simplecov' and SimpleCov.start do
	add_filter "spec/"
	add_filter "lib/mojito/utils/rspec.rb"
end
require 'mojito'
require 'mojito/utils/rspec'

describe Mojito::Rendering::Templates do
	
	context 'inline templates' do
		subject do
			Mojito::C.runtime_controller Mojito::Rendering::Templates do
				template :erb, 'before <%= var %> <%= yield %> after', :var => 'middle' do 'inside the block' end
				halt!
			end.mock_request
		end
		
		it { subject.get('/').should respond_with(200, 'before middle inside the block after') }
		
	end
	
	context 'file templates' do
		subject do
			Mojito::C.runtime_controller Mojito::R::Templates do
				template 'test.html.erb', :var => 'middle' do 'inside the block' end
				halt!
			end.mock_request
		end
		
		it { subject.get('/').should respond_with(200, 'HTML file with a variable middle and a yield inside the block', 'Content-Type' => 'text/html') }
		
		context 'text template' do
			subject do
				Mojito::C.runtime_controller Mojito::R::Templates do
					template 'test.txt.erb', :var => 'middle' do 'inside the block' end
					halt!
				end.mock_request
			end
			
			it { subject.get('/').should respond_with(200, 'Text file with a variable middle and a yield inside the block', 'Content-Type' => 'text/plain') }
			
		end
			
	end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mojito-0.2.6 spec/mojito/rendering/templates_spec.rb
mojito-0.2.5 spec/mojito/rendering/templates_spec.rb
mojito-0.2.4 spec/mojito/rendering/templates_spec.rb
mojito-0.2.3 spec/mojito/rendering/templates_spec.rb