class PhusionPassenger::Utils::ParserTest
Constants
- PARSED
Public Instance Methods
parse_string(str)
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 200 def parse_string(str) JSON.parse(%Q(["#{str}"]).gsub('\\', '\')).first end
parsed()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 199 def parsed() PARSED end
test_array()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 226 def test_array assert_equal ["4438f", {"a" => "b"}], parsed['head']['sha'] end
test_bool()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 219 def test_bool assert_equal true, parsed['head']['repository']['fork'] assert_equal false, parsed['head']['repository']['private'] end
test_hash()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 213 def test_hash assert_equal %w[label ref repository sha user], parsed['head'].keys.sort end
test_invalid()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 229 def test_invalid assert_raises(RuntimeError) { JSON.parse %Q({) } assert_raises(RuntimeError) { JSON.parse %Q({ "foo": }) } assert_raises(RuntimeError) { JSON.parse %Q([ "foo": "bar" ]) } assert_raises(RuntimeError) { JSON.parse %Q([ ~"foo" ]) } assert_raises(RuntimeError) { JSON.parse %Q([ "foo ]) } assert_raises(RuntimeError) { JSON.parse %Q([ "foo\\" ]) } assert_raises(RuntimeError) { JSON.parse %Q([ "foo\\uabGd" ]) } end
test_nil()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 223 def test_nil assert_nil parsed['head']['user']['company'] end
test_number()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 216 def test_number assert_equal 124.3e2, parsed['head']['repository']['size'] end
test_string()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 201 def test_string assert_equal "Pagination library for \"Rails 3\", Sinatra, Merb, DataMapper, and more", parsed['head']['repository']['description'] end
test_string_specials()
click to toggle source
# File lib/phusion_passenger/utils/json.rb, line 205 def test_string_specials assert_equal "\r\n\t\f\b", parse_string('\r\n\t\f\b') assert_equal "aA", parse_string('\u0061\u0041') assert_equal "\e", parse_string('\u001B') assert_equal "xyz", parse_string('\x\y\z') assert_equal '"\/', parse_string('\"\\\/') assert_equal 'no #{interpolation}', parse_string('no #{interpolation}') end