Skip to content

Commit

Permalink
Now works with jruby --1.9: use JSON instead of YAML in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matadon authored and dekellum committed Jan 21, 2012
1 parent 3434ff7 commit 4964ce4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 8 additions & 7 deletions spec/mizuno_spec.rb
Expand Up @@ -3,6 +3,7 @@
require 'thread'
require 'digest/md5'
require 'base64'
require 'json/pure'

describe Mizuno do
def get(path, headers = {})
Expand Down Expand Up @@ -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
Expand All @@ -62,29 +63,29 @@ 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

it "passes form variables via POST" do
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

Expand All @@ -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

Expand Down
4 changes: 3 additions & 1 deletion 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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 4964ce4

Please sign in to comment.