spec/unit/request_spec.rb in goliath-1.0.3 vs spec/unit/request_spec.rb in goliath-1.0.4

- old
+ new

@@ -1,10 +1,10 @@ require 'spec_helper' describe Goliath::Request do before(:each) do - app = mock('app').as_null_object + app = double('app').as_null_object env = Goliath::Env.new @r = Goliath::Request.new(app, nil, env) end @@ -26,12 +26,12 @@ end end describe 'process' do it 'executes the application' do - app_mock = mock('app').as_null_object - env_mock = mock('app').as_null_object + app_mock = double('app').as_null_object + env_mock = double('app').as_null_object request = Goliath::Request.new(app_mock, nil, env_mock) app_mock.should_receive(:call).with(request.env) request.should_receive(:post_process) @@ -52,26 +52,35 @@ end end describe 'parse_headers' do it 'sets content_type correctly' do - parser = mock('parser').as_null_object + parser = double('parser').as_null_object parser.stub(:request_url).and_return('') @r.parse_header({'Content-Type' => 'text/plain'}, parser) @r.env['CONTENT_TYPE'].should == 'text/plain' end + it 'handles bad request urls' do + parser = double('parser').as_null_object + parser.stub(:request_url).and_return('/bad?param}') + + @r.stub(:server_exception) + @r.should_receive(:server_exception) + @r.parse_header({}, parser) + end + it 'sets content_length correctly' do - parser = mock('parser').as_null_object + parser = double('parser').as_null_object parser.stub(:request_url).and_return('') @r.parse_header({'Content-Length' => 42}, parser) @r.env['CONTENT_LENGTH'].should == 42 end it 'sets server_name and server_port correctly' do - parser = mock('parser').as_null_object + parser = double('parser').as_null_object parser.stub(:request_url).and_return('') @r.parse_header({'Host' => 'myhost.com:3000'}, parser) @r.env['SERVER_NAME'].should == 'myhost.com' @r.env['SERVER_PORT'].should == '3000'