Skip to content

Commit

Permalink
Proper encoding test.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Sep 10, 2010
1 parent 222d2cb commit ea1426f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
18 changes: 18 additions & 0 deletions test/encoding_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# encoding: UTF-8
require File.dirname(__FILE__) + '/helper'

class BaseTest < Test::Unit::TestCase
setup do
@base = Sinatra.new(Sinatra::Base)
@base.set :views, File.dirname(__FILE__) + "/views"
end

it 'allows unicode strings in ascii templates per default (1.9)' do
@base.new.haml(:ascii, {}, :value => "åkej")
end

it 'allows ascii strings in unicode templates per default (1.9)' do
next unless defined? Encoding
@base.new.haml(:utf8, {}, :value => "Some Lyrics".encode("ASCII"))
end
end
8 changes: 0 additions & 8 deletions test/settings_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: UTF-8
require File.dirname(__FILE__) + '/helper'

class SettingsTest < Test::Unit::TestCase
Expand Down Expand Up @@ -375,11 +374,4 @@ def foo=(value)
assert ! @application.lock?
end
end

describe 'default_encoding' do
it 'allows unicode strings in ascii templates per default (1.9)' do
@base.set :views, File.dirname(__FILE__) + "/views"
@base.new.haml(:ascii, {}, :value => "åkej")
end
end
end
2 changes: 2 additions & 0 deletions test/views/utf8.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%h1= value
Ingen vill veta var du köpt din tröja.

0 comments on commit ea1426f

Please sign in to comment.