aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb
blob: ef680cafed60f629b78e42b395a8fbcdf2b8e4d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

module ActionDispatch
  module SystemTesting
    module TestHelpers
      module UndefMethods # :nodoc:
        extend ActiveSupport::Concern
        included do
          METHODS = %i(get post put patch delete).freeze

          METHODS.each do |verb|
            undef_method verb
          end

          def method_missing(method, *args, &block)
            if METHODS.include?(method)
              raise NoMethodError
            else
              super
            end
          end
        end
      end
    end
  end
end