diff options
author | Jesse Campbell <hikeit@gmail.com> | 2013-02-18 11:58:57 -0500 |
---|---|---|
committer | Jesse Campbell <hikeit@gmail.com> | 2013-02-18 11:58:57 -0500 |
commit | f372f8ca80444a038b7dfaf1a1f035de7e1a90ca (patch) | |
tree | 0e16521cb2d0e2e231cc9f04cce655d3603a628f /spec/tiny_server.rb | |
parent | f54a08a4111482afe78a3c3b521978c882c96652 (diff) | |
download | chef-f372f8ca80444a038b7dfaf1a1f035de7e1a90ca.tar.gz |
functional test for CHEF-3140
Diffstat (limited to 'spec/tiny_server.rb')
-rw-r--r-- | spec/tiny_server.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb index 9eecf13cec..eb5f5c0fc0 100644 --- a/spec/tiny_server.rb +++ b/spec/tiny_server.rb @@ -127,20 +127,20 @@ module TinyServer @routes = {GET => [], PUT => [], POST => [], DELETE => []} end - def get(path, response_code, data=nil, &block) - @routes[GET] << Route.new(path, Response.new(response_code,data, &block)) + def get(path, response_code, data=nil, headers=nil, &block) + @routes[GET] << Route.new(path, Response.new(response_code, data, headers, &block)) end - def put(path, response_code, data=nil, &block) - @routes[PUT] << Route.new(path, Response.new(response_code,data, &block)) + def put(path, response_code, data=nil, headers=nil, &block) + @routes[PUT] << Route.new(path, Response.new(response_code, data, headers, &block)) end - def post(path, response_code, data=nil, &block) - @routes[POST] << Route.new(path, Response.new(response_code,data, &block)) + def post(path, response_code, data=nil, headers=nil, &block) + @routes[POST] << Route.new(path, Response.new(response_code, data, headers, &block)) end - def delete(path, response_code, data=nil, &block) - @routes[DELETE] << Route.new(path, Response.new(response_code,data, &block)) + def delete(path, response_code, data=nil, headers=nil, &block) + @routes[DELETE] << Route.new(path, Response.new(response_code, data, headers, &block)) end def call(env) @@ -183,14 +183,15 @@ module TinyServer class Response HEADERS = {'Content-Type' => 'application/json'} - def initialize(response_code=200,data=nil, &block) + def initialize(response_code=200, data=nil, headers=nil, &block) @response_code, @data = response_code, data + @response_headers = headers ? HEADERS.merge(headers) : HEADERS @block = block_given? ? block : nil end def call data = @data || @block.call - [@response_code, HEADERS, Array(data)] + [@response_code, @response_headers, Array(data)] end def to_s |