From 4964ce448df40d5c1c56d50d8c38fa224980a595 Mon Sep 17 00:00:00 2001 From: Don Werve Date: Wed, 16 Nov 2011 06:21:18 -0800 Subject: [PATCH] Now works with jruby --1.9: use JSON instead of YAML in tests --- spec/mizuno_spec.rb | 15 ++++++++------- spec/test_app.rb | 4 +++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spec/mizuno_spec.rb b/spec/mizuno_spec.rb index ffc3110..7313600 100644 --- a/spec/mizuno_spec.rb +++ b/spec/mizuno_spec.rb @@ -3,6 +3,7 @@ require 'thread' require 'digest/md5' require 'base64' +require 'json/pure' describe Mizuno do def get(path, headers = {}) @@ -52,7 +53,7 @@ def post(path, params = nil, headers = {}, body = nil) it "sets Rack headers" do response = get("/echo") response.code.should == "200" - content = YAML.load(response.body) + content = JSON.parse(response.body) content["rack.version"].should == [ 1, 1 ] content["rack.multithread"].should be_true content["rack.multiprocess"].should be_false @@ -62,7 +63,7 @@ def post(path, params = nil, headers = {}, body = nil) it "passes form variables via GET" do response = get("/echo?answer=42") response.code.should == "200" - content = YAML.load(response.body) + content = JSON.parse(response.body) content['request.params']['answer'].should == '42' end @@ -70,21 +71,21 @@ def post(path, params = nil, headers = {}, body = nil) question = "What is the answer to life, the universe, and everything?" response = post("/echo", 'question' => question) response.code.should == "200" - content = YAML.load(response.body) + content = JSON.parse(response.body) content['request.params']['question'].should == question end it "passes custom headers" do response = get("/echo", "X-My-Header" => "Pancakes") response.code.should == "200" - content = YAML.load(response.body) + content = JSON.parse(response.body) content["HTTP_X_MY_HEADER"].should == "Pancakes" end it "lets the Rack app know it's running as a servlet" do response = get("/echo", 'answer' => '42') response.code.should == "200" - content = YAML.load(response.body) + content = JSON.parse(response.body) content['rack.java.servlet'].should be_true end @@ -95,14 +96,14 @@ def post(path, params = nil, headers = {}, body = nil) it "sets the server port and hostname" do response = get("/echo") - content = YAML.load(response.body) + content = JSON.parse(response.body) content["SERVER_PORT"].should == "9201" content["SERVER_NAME"].should == "127.0.0.1" end it "passes the URI scheme" do response = get("/echo") - content = YAML.load(response.body) + content = JSON.parse(response.body) content['rack.url_scheme'].should == 'http' end diff --git a/spec/test_app.rb b/spec/test_app.rb index 3ce8389..0a88958 100644 --- a/spec/test_app.rb +++ b/spec/test_app.rb @@ -1,3 +1,5 @@ +require 'json/pure' + # # A tiny Rack application for testing the Mizuno webserver. Each of the # following paths can be used to test webserver behavior: @@ -49,7 +51,7 @@ def error(request, code = nil) def echo(request) response = Rack::Response.new env = request.env.merge('request.params' => request.params) - response.write(env.to_yaml) + response.write(env.to_json) response.finish end