Skip to content

Commit

Permalink
Fixed nearly introduced bug. Ref #79
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Oct 16, 2015
1 parent 1b83cae commit 2288a5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lotus/view/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module View
# @since 0.1.0
class Template
def initialize(template, encoding)
@_template = Tilt.new(template, encoding)
@_template = Tilt.new(template, nil, default_encoding: encoding)
end

# Returns the format that the template handles.
Expand Down
14 changes: 14 additions & 0 deletions test/rendering_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
EncodingView.render(format: :html).must_include %(Configuração)
end

# See https://github.com/lotus/view/issues/76
it 'raises error when given encoding is not correct' do
exception = -> {
Class.new do
include Lotus::View
configuration.default_encoding 'wrong'

def self.name; 'EncodingView'; end
end.render(format: :html)
}.must_raise ArgumentError

exception.message.must_include "unknown encoding name - wrong"
end

it 'renders a template according to the declared format' do
JsonRenderView.render(format: :json, planet: 'Moon').must_include %("greet":"Hello, Moon!")
end
Expand Down

0 comments on commit 2288a5d

Please sign in to comment.