diff options
Diffstat (limited to 'actionview/lib/action_view/testing/resolvers.rb')
-rw-r--r-- | actionview/lib/action_view/testing/resolvers.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb index 1fad08a689..1bedf44934 100644 --- a/actionview/lib/action_view/testing/resolvers.rb +++ b/actionview/lib/action_view/testing/resolvers.rb @@ -8,36 +8,37 @@ module ActionView #:nodoc: # useful for testing extensions that have no way of knowing what the file # system will look like at runtime. class FixtureResolver < PathResolver - attr_reader :hash - def initialize(hash = {}, pattern = nil) super(pattern) @hash = hash end + def data + @hash + end + def to_s @hash.keys.join(", ") end private - def query(path, exts, _, _) + def query(path, exts, _, locals, cache:) query = +"" - EXTENSIONS.each_key do |ext| - query << "(" << exts[ext].map { |e| e && Regexp.escape(".#{e}") }.join("|") << "|)" + EXTENSIONS.each do |ext, prefix| + query << "(" << exts[ext].map { |e| e && Regexp.escape("#{prefix}#{e}") }.join("|") << "|)" end query = /^(#{Regexp.escape(path)})#{query}$/ templates = [] - @hash.each do |_path, array| - source, updated_at = array + @hash.each do |_path, source| next unless query.match?(_path) handler, format, variant = extract_handler_and_format_and_variant(_path) templates << Template.new(source, _path, handler, virtual_path: path.virtual, format: format, variant: variant, - updated_at: updated_at + locals: locals ) end @@ -46,9 +47,9 @@ module ActionView #:nodoc: end class NullResolver < PathResolver - def query(path, exts, _, _) + def query(path, exts, _, locals, cache:) handler, format, variant = extract_handler_and_format_and_variant(path) - [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)] + [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant, locals: locals)] end end end |