Sha256: faa9a56b1d4e4eea94ca682f099a140a60c7cfe0a531dc30d82d589cb4dd1237

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

require "rack"

module Lita
  module RSpec
    # A namespace to hold all of Lita's RSpec matchers.
    module Matchers
      # RSpec matchers for HTTP routes.
      # @since 4.0.0
      module HTTPRouteMatcher
        extend ::RSpec::Matchers::DSL

        matcher :route_http do |http_method, path|
          match do
            env = Rack::MockRequest.env_for(path, method: http_method)

            matching_routes = robot.app.recognize(env)

            if defined?(@method_name)
              matching_routes.include?(@method_name)
            else
              !matching_routes.empty?
            end
          end

          chain :to do |method_name|
            @method_name = method_name
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rita-5.0.0.alpha.4 lib/lita/rspec/matchers/http_route_matcher.rb
rita-5.0.0.alpha.3 lib/lita/rspec/matchers/http_route_matcher.rb
rita-5.0.0.alpha.2 lib/lita/rspec/matchers/http_route_matcher.rb
rita-5.0.0.alpha.1 lib/lita/rspec/matchers/http_route_matcher.rb