### Home Classes Methods

### In Files

- lib/phusion_passenger/utils/json.rb

### Parent

Test::Unit::TestCase

### Methods

- #parse_string
- #parsed
- #test_array
- #test_bool
- #test_hash
- #test_invalid
- #test_nil
- #test_number
- #test_string
- #test_string_specials

### Class/Module Index

Quicksearch

- PhusionPassenger
- PhusionPassenger::AbstractInstaller
- PhusionPassenger::AbstractInstaller::Abort
- PhusionPassenger::AbstractInstaller::CommandError
- PhusionPassenger::AdminTools
- PhusionPassenger::AdminTools::MemoryStats
- PhusionPassenger::AdminTools::MemoryStats::Process
- PhusionPassenger::AdminTools::ServerInstance
- PhusionPassenger::AdminTools::ServerInstance::CorruptedDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::GenerationsAbsentError
- PhusionPassenger::AdminTools::ServerInstance::Group
- PhusionPassenger::AdminTools::ServerInstance::Process
- PhusionPassenger::AdminTools::ServerInstance::RoleDeniedError
- PhusionPassenger::AdminTools::ServerInstance::StaleDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::Stats
- PhusionPassenger::AdminTools::ServerInstance::UnsupportedGenerationStructureVersionError
- PhusionPassenger::AnalyticsLogger
- PhusionPassenger::AnalyticsLogger::Connection
- PhusionPassenger::AnalyticsLogger::Lock
- PhusionPassenger::AnalyticsLogger::Log
- PhusionPassenger::ClassicRails
- PhusionPassenger::ClassicRails::CGIFixed
- PhusionPassenger::ClassicRails::ThreadHandlerExtension
- PhusionPassenger::ConsoleTextTemplate
- PhusionPassenger::DebugLogging
- PhusionPassenger::LoaderSharedHelpers
- PhusionPassenger::MessageChannel
- PhusionPassenger::MessageChannel::InvalidHashError
- PhusionPassenger::MessageClient
- PhusionPassenger::NativeSupportLoader
- PhusionPassenger::Packaging
- PhusionPassenger::PlatformInfo
- PhusionPassenger::PlatformInfo::ApacheDetector
- PhusionPassenger::PlatformInfo::ApacheDetector::Result
- PhusionPassenger::PlatformInfo::Depcheck
- PhusionPassenger::PlatformInfo::Depcheck::ConsoleRunner
- PhusionPassenger::PlatformInfo::Depcheck::Dependency
- PhusionPassenger::PlatformInfo::RuntimeError
- PhusionPassenger::Plugin
- PhusionPassenger::PreloaderSharedHelpers
- PhusionPassenger::Rack
- PhusionPassenger::Rack::OutOfBandGc
- PhusionPassenger::Rack::ThreadHandlerExtension
- PhusionPassenger::Rails3Extensions
- PhusionPassenger::Rails3Extensions::AnalyticsLogging
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ExceptionLogger
- PhusionPassenger::RequestHandler
- PhusionPassenger::RequestHandler::ThreadHandler
- PhusionPassenger::RequestHandler::ThreadHandler::Interrupted
- PhusionPassenger::SharedConstants
- PhusionPassenger::Standalone
- PhusionPassenger::Standalone::AppFinder
- PhusionPassenger::Standalone::Command
- PhusionPassenger::Standalone::ConfigFile
- PhusionPassenger::Standalone::ConfigFile::DisallowedContextError
- PhusionPassenger::Standalone::HelpCommand
- PhusionPassenger::Standalone::Main
- PhusionPassenger::Standalone::PackageRuntimeCommand
- PhusionPassenger::Standalone::RuntimeInstaller
- PhusionPassenger::Standalone::RuntimeLocator
- PhusionPassenger::Standalone::StartCommand
- PhusionPassenger::Standalone::StatusCommand
- PhusionPassenger::Standalone::StopCommand
- PhusionPassenger::Standalone::Utils
- PhusionPassenger::Standalone::VersionCommand
- PhusionPassenger::Utils
- PhusionPassenger::Utils::AnsiColors
- PhusionPassenger::Utils::FileSystemWatcher
- PhusionPassenger::Utils::FileSystemWatcher::DirInfo
- PhusionPassenger::Utils::FileSystemWatcher::FileInfo
- PhusionPassenger::Utils::GeneratorTest
- PhusionPassenger::Utils::HostsFileParser
- PhusionPassenger::Utils::JSON
- PhusionPassenger::Utils::JSON::Generator
- PhusionPassenger::Utils::ParserTest
- PhusionPassenger::Utils::TeeInput
- PhusionPassenger::Utils::TmpIO
- PhusionPassenger::Utils::UnseekableSocket
- CommonLibraryBuilder
- Exception
- GC
- IO
- Object
- Signal

No matching classes.

# 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(%(["#{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 ]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 %({) }
      assert_raises(RuntimeError) { JSON.parse %({ "foo": }) }
      assert_raises(RuntimeError) { JSON.parse %([ "foo": "bar" ]) }
      assert_raises(RuntimeError) { JSON.parse %([ ~"foo" ]) }
      assert_raises(RuntimeError) { JSON.parse %([ "foo ]) }
      assert_raises(RuntimeError) { JSON.parse %([ "foo\\" ]) }
      assert_raises(RuntimeError) { JSON.parse %([ "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

[Validate]

Generated with the Darkfish Rdoc Generator 2.