Sha256: 6d5e34f8fb00a6b3bf48f9ed61b0d6a8d0a28c4e1d39ee06b8fc7fb12109506c

Contents?: true

Size: 1.16 KB

Versions: 19

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

# Controller used in various examples.
class UsersController < ActiveElement::ApplicationController
  def initialize(*args, &block)
    append_view_path File.expand_path(File.join(__dir__, '../app/views/'))

    super
  end

  def params
    {}
  end

  def helpers
    @helpers ||= Helpers.new
  end

  def request
    @_request = Session.new
    @request ||= Request.new
  end
end

# Stand-in for Rails controller helpers.
class Helpers
  def pet_path(record = nil)
    "/pet/#{record&.id}"
  end

  def user_path(record = nil)
    "/user/#{record&.id}"
  end

  def edit_user_path(record)
    "/user/#{record.id}/edit"
  end

  def new_user_path(*_args)
    '/users/new'
  end

  def render(*args)
    ActionController::Base.new.render_to_string(*args)
  end
end

# Stand-in for a Rails Request.
class Request
  def path
    '/users/new'
  end

  def host
    'www.example.com'
  end

  def optional_port
    80
  end

  def protocol
    'http'
  end

  def path_parameters
    {}
  end

  def method_missing(*)
    nil
  end

  def respond_to_missing?(*)
    true
  end
end

# Stand-in for a Rails Session.
class Session
  def session
    {}
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
active_element-0.0.31 rspec-documentation/support.rb
active_element-0.0.30 rspec-documentation/support.rb
active_element-0.0.29 rspec-documentation/support.rb
active_element-0.0.28 rspec-documentation/support.rb
active_element-0.0.27 rspec-documentation/support.rb
active_element-0.0.26 rspec-documentation/support.rb
active_element-0.0.24 rspec-documentation/support.rb
active_element-0.0.23 rspec-documentation/support.rb
active_element-0.0.22 rspec-documentation/support.rb
active_element-0.0.21 rspec-documentation/support.rb
active_element-0.0.19 rspec-documentation/support.rb
active_element-0.0.18 rspec-documentation/support.rb
active_element-0.0.17 rspec-documentation/support.rb
active_element-0.0.16 rspec-documentation/support.rb
active_element-0.0.15 rspec-documentation/support.rb
active_element-0.0.14 rspec-documentation/support.rb
active_element-0.0.13 rspec-documentation/support.rb
active_element-0.0.12 rspec-documentation/support.rb
active_element-0.0.11 rspec-documentation/support.rb