Sha256: 2ca2a38565ea63a7c8c4e5d332be9dd6c93f2657366cd42bba1903a806436ca4

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Quarto::Rendering do
	context '.render' do
		it 'should use the ERB template' do
			template = ERB.new 'foo bar'
			Quarto::Rendering.render(template, {}).should == 'foo bar'
		end
		
		it 'should set the local variables' do
			template = ERB.new 'The value of x is <%= x %>.'
			Quarto::Rendering.render(template, {:x => 42}).should == 'The value of x is 42.'
		end
		
		it 'should mix in the modules' do
			module SomeMixin
				def foo; 42; end
			end
			template = ERB.new 'SomeMixin#foo returns <%= foo %>.'
			Quarto::Rendering.render(template, {}, [SomeMixin]).should == 'SomeMixin#foo returns 42.'
			Object.class_eval do
				remove_const :SomeMixin
			end
		end
		
		it 'should raise ArgumentError if the first parameter is not an ERB template' do
			lambda { Quarto::Rendering.render('foo bar', {}) }.should raise_error(ArgumentError)
		end
		
		it 'should raise ArgumentError if the second parameter is not a hash' do
			template = ERB.new 'foo bar'
			lambda { Quarto::Rendering.render(template, [:x, 42]) }.should raise_error(ArgumentError)
		end
		
		it 'should raise ArgumentError if the third parameter is not an array of modules' do
			module SomeMixin; end
			template = ERB.new 'foo bar'
			lambda { Quarto::Rendering.render(template, {}, SomeMixin) }.should raise_error(ArgumentError)
			lambda { Quarto::Rendering.render(template, {}, [SomeMixin, 'foo']) }.should raise_error(ArgumentError)
			Object.class_eval do
				remove_const :SomeMixin
			end
		end
	end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jarrett-quarto-1.2.0 spec/rendering_spec.rb
jarrett-quarto-1.2.1 spec/rendering_spec.rb
jarrett-quarto-1.3.0 spec/rendering_spec.rb
jarrett-quarto-1.4.0 spec/rendering_spec.rb
jarrett-quarto-1.4.1 spec/rendering_spec.rb
jarrett-quarto-1.5.0 spec/rendering_spec.rb
jarrett-quarto-1.5.1 spec/rendering_spec.rb
jarrett-quarto-1.6.1 spec/rendering_spec.rb
jarrett-quarto-1.6.2 spec/rendering_spec.rb
jarrett-quarto-1.6.3 spec/rendering_spec.rb