Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

switch to multi_json

  • Loading branch information...
commit 1aed9fbcee90394c20ab8066cd0936fcf6e728ed 1 parent 266cb12
@joshbuddy authored
View
6 Gemfile.lock
@@ -2,19 +2,19 @@ PATH
remote: .
specs:
rack-webconsole (0.1.2)
- json
+ multi_json (~> 1.0.3)
rack
GEM
remote: http://rubygems.org/
specs:
bluecloth (2.1.0)
- json (1.5.3)
minitest (2.3.1)
mocha (0.9.12)
+ multi_json (1.0.3)
purdytest (1.0.0)
minitest (~> 2.2)
- rack (1.3.1)
+ rack (1.3.2)
rake (0.9.2)
yard (0.7.2)
View
4 lib/rack/webconsole/repl.rb
@@ -1,5 +1,5 @@
# encoding: utf-8
-require 'json'
+require 'multi_json'
require 'digest/sha1'
module Rack
@@ -87,7 +87,7 @@ def call(env)
rescue=>e
"Error: " + e.message
end
- response_body = {:result => result}.to_json
+ response_body = MultiJson.encode(:result => result)
headers = {}
headers['Content-Type'] = 'application/json'
headers['Content-Length'] = response_body.bytesize.to_s
View
3  rack-webconsole.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.rubyforge_project = "rack-webconsole"
s.add_runtime_dependency 'rack'
- s.add_runtime_dependency 'json'
+ s.add_runtime_dependency 'multi_json', '~> 1.0.3'
s.add_development_dependency 'minitest'
s.add_development_dependency 'purdytest'
@@ -25,6 +25,5 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
end
View
6 spec/rack/webconsole/repl_spec.rb
@@ -23,7 +23,7 @@ module Rack
response = @repl.call(env).last.first
- JSON.parse(response)['result'].must_equal "8"
+ MultiJson.decode(response)['result'].must_equal "8"
end
it 'maintains local state in subsequent calls thanks to an evil global variable' do
@@ -41,7 +41,7 @@ module Rack
response = @repl.call(env).last.first # call 2 retrieves a and multiplies it by 8
- JSON.parse(response)['result'].must_equal "32"
+ MultiJson.decode(response)['result'].must_equal "32"
$sandbox.instance_variable_get(:@locals)[:a].must_equal 4
$sandbox.instance_variable_get(:@locals).size.must_equal 1
end
@@ -56,7 +56,7 @@ module Rack
response = @repl.call(env).last.first
- JSON.parse(response)['result'].must_match /Error:/
+ MultiJson.decode(response)['result'].must_match /Error:/
end
it 'rejects non-post requests' do
Please sign in to comment.
Something went wrong with that request. Please try again.