Sha256: ccc61c34bf8121dfc2d64e8a3015148e36020fb59e677e51c63fd77b010ec396

Contents?: true

Size: 1.19 KB

Versions: 80

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require "action_view/template/resolver"

module ActionView # :nodoc:
  # Use FixtureResolver in your tests to simulate the presence of files on the
  # file system. This is used internally by Rails' own test suite, and is
  # useful for testing extensions that have no way of knowing what the file
  # system will look like at runtime.
  class FixtureResolver < FileSystemResolver
    def initialize(hash = {})
      super("")
      @hash = hash
      @path = ""
    end

    def data
      @hash
    end

    def to_s
      @hash.keys.join(", ")
    end

    private
      def template_glob(glob)
        @hash.keys.filter_map do |path|
          "/#{path}" if File.fnmatch(glob, path)
        end
      end

      def source_for_template(template)
        @hash[template.from(1)]
      end
  end

  class NullResolver < Resolver
    def find_templates(name, prefix, partial, details, locals = [])
      path = TemplatePath.build(name, prefix, partial)
      handler = ActionView::Template::Handlers::Raw
      [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: nil, variant: nil, locals: locals)]
    end
  end
end

Version data entries

80 entries across 77 versions & 8 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/actionview-7.1.3.4/lib/action_view/testing/resolvers.rb
actionview-8.0.1 lib/action_view/testing/resolvers.rb
actionview-8.0.0.1 lib/action_view/testing/resolvers.rb
actionview-7.2.2.1 lib/action_view/testing/resolvers.rb
actionview-7.1.5.1 lib/action_view/testing/resolvers.rb
actionview-7.0.8.7 lib/action_view/testing/resolvers.rb
actionview-8.0.0 lib/action_view/testing/resolvers.rb
actionview-7.2.2 lib/action_view/testing/resolvers.rb
actionview-7.1.5 lib/action_view/testing/resolvers.rb
actionview-8.0.0.rc2 lib/action_view/testing/resolvers.rb
actionview-7.2.1.2 lib/action_view/testing/resolvers.rb
actionview-7.1.4.2 lib/action_view/testing/resolvers.rb
actionview-7.0.8.6 lib/action_view/testing/resolvers.rb
actionview-8.0.0.rc1 lib/action_view/testing/resolvers.rb
actionview-7.2.1.1 lib/action_view/testing/resolvers.rb
actionview-7.1.4.1 lib/action_view/testing/resolvers.rb
actionview-7.0.8.5 lib/action_view/testing/resolvers.rb
actionview-8.0.0.beta1 lib/action_view/testing/resolvers.rb
omg-actionview-8.0.0.alpha9 lib/action_view/testing/resolvers.rb
omg-actionview-8.0.0.alpha8 lib/action_view/testing/resolvers.rb