Sha256: 59a24365e36b578341b50801707c01e62ca1be46ffcdbb117a44d7f0f16ae714

Contents?: true

Size: 1.72 KB

Versions: 27

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

# some useful test objects

module ExceptionHandling
  module Testing
    class ControllerStubBase

      class Request
        attr_accessor :parameters, :protocol, :host, :request_uri, :env, :session_options

        def initialize
          @parameters  = { id: "1" }
          @protocol    = 'http'
          @host        = 'localhost'
          @request_uri = "/fun/testing.html?foo=bar"
          @env         = { HOST: "local" }
          @session_options = { id: '93951506217301' }
        end
      end

      attr_accessor :request, :session

      class << self
        attr_accessor :around_filter_method

        def around_filter(method)
          self.around_filter_method = method
        end
      end

      def initialize
        @request = Request.new
        @session_id = "ZKL95"
        @session =
          if defined?(Username)
            {
              login_count: 22,
              username_id: Username.first.id,
              user_id: User.first.id,
            }
          else
            {}
          end
      end

      def action_name
        "test_action"
      end

      def complete_request_uri
        "#{@request.protocol}#{@request.host}#{@request.request_uri}"
      end
    end

    class LoggingMethodsControllerStub < ControllerStubBase
      include ExceptionHandling::LoggingMethods

      def controller_name
        "LoggingMethodsControllerStub"
      end
    end

    class MethodsControllerStub < ControllerStubBase
      include ExceptionHandling::Methods
      set_long_controller_action_timeout 2

      def simulate_around_filter(&block)
        set_current_controller(&block)
      end

      def controller_name
        "MethodsControllerStub"
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
exception_handling-2.17.0.pre.tstarck.1 lib/exception_handling/testing.rb
exception_handling-2.16.0 lib/exception_handling/testing.rb
exception_handling-2.15.0 lib/exception_handling/testing.rb
exception_handling-2.14.0 lib/exception_handling/testing.rb
exception_handling-2.14.0.pre.gk.1 lib/exception_handling/testing.rb
exception_handling-2.14.0.pre.gk.0 lib/exception_handling/testing.rb
exception_handling-2.13.0 lib/exception_handling/testing.rb
exception_handling-2.13.0.pre.dc.0 lib/exception_handling/testing.rb
exception_handling-2.12.0 lib/exception_handling/testing.rb
exception_handling-2.12.0.gfaza.1 lib/exception_handling/testing.rb
exception_handling-2.11.4.gfaza.1 lib/exception_handling/testing.rb
exception_handling-2.11.3 lib/exception_handling/testing.rb
exception_handling-2.11.2 lib/exception_handling/testing.rb
exception_handling-2.11.1 lib/exception_handling/testing.rb
exception_handling-2.11.0 lib/exception_handling/testing.rb
exception_handling-2.10.0 lib/exception_handling/testing.rb
exception_handling-2.10.0.pre.2 lib/exception_handling/testing.rb
exception_handling-2.10.0.pre.1 lib/exception_handling/testing.rb
exception_handling-2.9.0 lib/exception_handling/testing.rb
exception_handling-2.9.0.pre.1 lib/exception_handling/testing.rb