test/value_test.rb in json_builder-3.0.7 vs test/value_test.rb in json_builder-3.1.0
- old
+ new
@@ -1,16 +1,14 @@
+# encoding: UTF-8
+
require 'test_helper'
class TestValue < Test::Unit::TestCase
def value(value)
JSONBuilder::Value.new(nil, value).to_s
end
- def test_is_a_builder_value
- assert_equal JSONBuilder::Value, JSONBuilder::Value.new(nil, true).class
- end
-
def test_positive_value
assert_equal '1', value(1)
end
def test_negative_value
@@ -35,15 +33,24 @@
def test_symbol_value
assert_equal 'test', value(:test)
end
+ def test_unicode_char_value
+ assert_equal '"hellyé"', value('hellyé')
+ end
+
def test_time_value
assert_equal '"2012-01-01T00:00:00Z"', value(Time.utc(2012))
end
+ def test_time_with_zone_value
+ Time.zone = 'CET'
+ assert_equal '"2012-01-01T00:00:00+01:00"', value(Time.zone.local(2012))
+ end
+
+ # This will be the local time zone offset, hence the wildcard.
def test_date_value
- # This will be the local time zone offset, hence the wildcard.
assert_match /"2012-01-01T00:00:00.*/, value(Date.parse('2012-01-01'))
end
def test_date_time_value
assert_equal '"2012-01-01T00:00:00Z"', value(DateTime.parse('2012-01-01'))