diff options
Diffstat (limited to 'spec/tiny_server.rb')
-rw-r--r-- | spec/tiny_server.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb index 7a58328224..a3711e4dbd 100644 --- a/spec/tiny_server.rb +++ b/spec/tiny_server.rb @@ -31,7 +31,7 @@ module TinyServer attr_writer :app - def self.setup(options=nil, &block) + def self.setup(options = nil, &block) tiny_app = new(options) app_code = Rack::Builder.new(&block).to_app tiny_app.app = app_code @@ -56,7 +56,7 @@ module TinyServer :AccessLog => [] # Remove this option to enable the access log when debugging. } - def initialize(options=nil) + def initialize(options = nil) @options = options ? DEFAULT_OPTIONS.merge(options) : DEFAULT_OPTIONS @creator = caller.first end @@ -128,22 +128,22 @@ module TinyServer end def clear - @routes = {GET => [], PUT => [], POST => [], DELETE => []} + @routes = { GET => [], PUT => [], POST => [], DELETE => [] } end - def get(path, response_code, data=nil, headers=nil, &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, headers=nil, &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, headers=nil, &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, headers=nil, &block) + def delete(path, response_code, data = nil, headers = nil, &block) @routes[DELETE] << Route.new(path, Response.new(response_code, data, headers, &block)) end @@ -151,11 +151,11 @@ module TinyServer if response = response_for_request(env) response.call else - debug_info = {:message => "no data matches the request for #{env['REQUEST_URI']}", - :available_routes => @routes, :request => env} + debug_info = { :message => "no data matches the request for #{env['REQUEST_URI']}", + :available_routes => @routes, :request => env } # Uncomment me for glorious debugging # pp :not_found => debug_info - [404, {"Content-Type" => "application/json"}, [ Chef::JSONCompat.to_json(debug_info) ]] + [404, { "Content-Type" => "application/json" }, [ Chef::JSONCompat.to_json(debug_info) ]] end end @@ -185,9 +185,9 @@ module TinyServer end class Response - HEADERS = {"Content-Type" => "application/json"} + HEADERS = { "Content-Type" => "application/json" } - def initialize(response_code=200, data=nil, headers=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 @@ -199,7 +199,7 @@ module TinyServer end def to_s - "#{@response_code} => #{(@data|| @block)}" + "#{@response_code} => #{(@data || @block)}" end end |