File: view_test_helper.rb

package info (click to toggle)
ruby-enumerize 2.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 432 kB
  • sloc: ruby: 3,712; makefile: 6
file content (46 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require 'active_support/concern'
require 'active_support/testing/setup_and_teardown'

if defined?(ActionView::RoutingUrlFor)
  ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
end

module SetupAndTeardownHelper
  extend ActiveSupport::Concern

  include ActiveSupport::Testing::SetupAndTeardown

  included do
    include ActiveSupport::Callbacks
    define_callbacks :setup, :teardown
  end
end

module ViewTestHelper
  extend ActiveSupport::Concern

  include SetupAndTeardownHelper
  include ActionView::TestCase::Behavior

  included do
    setup :set_controller
  end

  def set_controller
    @controller = MockController.new
  end

  def method_missing(method, *args)
    super unless method.to_s =~ /_path$/
  end

  def respond_to?(method, include_private=false)
    method.to_s =~ /_path$/ || super
  end

  def protect_against_forgery?
    false
  end
end