lib/watirspec/server/app.rb in watir-6.13.0 vs lib/watirspec/server/app.rb in watir-6.14.0

- old
+ new

@@ -8,26 +8,34 @@ when '/post_to_me' respond("You posted the following content:\n#{data}") when '/plain_text' respond('This is text/plain', 'Content-Type' => 'text/plain') when %r{/set_cookie} - respond("<html>C is for cookie, it's good enough for me</html>", 'Content-Type' => 'text/html', 'Set-Cookie' => 'monster=1') + body = "<html>C is for cookie, it's good enough for me</html>" + respond(body, 'Content-Type' => 'text/html', 'Set-Cookie' => 'monster=1') + when static_file? + respond_to_file(path) + else + respond('') + end + end + + private + + def respond_to_file(path) + case path when css_file? respond(file_read(path), 'Content-Type' => 'text/css') when js_file? respond(file_read(path), 'Content-Type' => 'application/javascript') when png_file? respond(file_binread(path), 'Content-Type' => 'image/png') when gif_file? respond(file_read(path), 'Content-Type' => 'image/gif') - when static_file? - respond(file_read(path)) else - respond('') + respond(file_read(path)) end end - - private def respond(body, headers = {}, status = '200 OK') [status, headers, body] end