support jsonify filter

This commit is contained in:
liufengyun
2013-10-22 18:04:32 +08:00
parent 58ae8bc0cd
commit f971aebfb1
3 changed files with 32 additions and 0 deletions

View File

@@ -98,5 +98,16 @@ class TestFilters < Test::Unit::TestCase
should "escape space as %20" do
assert_equal "my%20things", @filter.uri_escape("my things")
end
context "jsonify filter" do
should "convert hash to json" do
assert_equal "{\"age\":18}", @filter.jsonify({:age => 18})
end
should "convert array to json" do
assert_equal "[1,2]", @filter.jsonify([1, 2])
assert_equal "[{\"name\":\"Jack\"},{\"name\":\"Smith\"}]", @filter.jsonify([{:name => 'Jack'}, {:name => 'Smith'}])
end
end
end
end