Sha256: 92c40b78ab03f408683a8ec3be9909840ce84551631b33d6ad5be491815b91dd

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

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

      def call(env)
        @env = env

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

        if is_html_response? && !tested_action?
          append_warning
        end

        [@status, @headers, @response]
      end

    private

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

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

      def warning_template
        ERB.new(File.open(File.join(File.dirname(__FILE__), "..", "templates", "warning.html.erb")).read).result(binding)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
route_dog-2.5.1 lib/route_dog/middleware/notifier.rb
route_dog-2.5.0 lib/route_dog/middleware/notifier.rb