Sha256: af2a3c99fc78210497c5eb487b13f275f54ff2d1276ff3561ba0be762353ebeb

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 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)

        append_warning if !::RouteDog.route_tested_with_requirements?(identify_controller, identify_action, request_method)

        [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

1 entries across 1 versions & 1 rubygems

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