Sha256: 2d4f39fef69781ffb5bd47b2b7419ec196af4dd89d87a63351d234724242cddd

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module RouteDog
  module Middleware
    class Notifier < RouteDog
      def initialize(app)
        @app = app
        super
      end

      def call(env)
        @env = env

        status, headers, @response = @app.call(env)

        append_warning if !route_tested?

        [status, headers, @response]
      end

      def append_warning
        @response.each do |part|
          part.gsub!("<body>", "<body>#{warning_html}")
        end
      end

      def no_test_message
        "The Route #{request_method.to_s.upcase} #{identify_controller.to_s}##{identify_action.to_s} -- Has Not Integrational Tests!"
      end

      def warning_html
        <<-EOT
          <div style="display: block; height:70px;"></div>
          <div id="route_dog_warning" style="display: block; width: 100%; height: 70px; text-align: center; margin:0; position:absolute; top:0; background: red; font-size: 18px; font-weight: bold">
            <h1 style="color: #fff; font-size: 20px; margin: 20px 0 35px">#{no_test_message}</h1>
          </div>
        EOT
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
route_dog-2.0.1 lib/route_dog/middleware/notifier.rb