Permalink
Browse files

switch to multi_json

  • Loading branch information...
joshbuddy committed Aug 4, 2011
1 parent 266cb12 commit 1aed9fbcee90394c20ab8066cd0936fcf6e728ed
Showing with 9 additions and 10 deletions.
  1. +3 −3 Gemfile.lock
  2. +2 −2 lib/rack/webconsole/repl.rb
  3. +1 −2 rack-webconsole.gemspec
  4. +3 −3 spec/rack/webconsole/repl_spec.rb
View
@@ -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)
@@ -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
@@ -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
@@ -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

0 comments on commit 1aed9fb

Please sign in to comment.