Skip to content

Commit d6fd648

Browse files
JonRowebquorning
authored andcommitted
add spec covering regression where arrays where not supported for append/prepend and fix
1 parent 20f48e3 commit d6fd648

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/rspec/rails/view_rendering.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ def self.call(_template)
7171
# @private
7272
module EmptyTemplates
7373
def prepend_view_path(new_path)
74-
lookup_context.view_paths.unshift(*_path_decorator(new_path))
74+
lookup_context.view_paths.unshift(*_path_decorator(*new_path))
7575
end
7676

7777
def append_view_path(new_path)
78-
lookup_context.view_paths.push(*_path_decorator(new_path))
78+
lookup_context.view_paths.push(*_path_decorator(*new_path))
7979
end
8080

8181
private
8282

83-
def _path_decorator(path)
84-
EmptyTemplateResolver.new(path)
83+
def _path_decorator(*paths)
84+
paths.map { |path| EmptyTemplateResolver.new(path) }
8585
end
8686
end
8787

spec/rspec/rails/view_rendering_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ def example.controller
133133
expect(controller.view_paths.map(&:to_s)).to match_paths 'app/views', 'app/others'
134134
end
135135

136+
it 'supports manipulating view paths with arrays' do
137+
controller.prepend_view_path ['app/views', 'app/legacy_views']
138+
controller.append_view_path ['app/others', 'app/more_views']
139+
expect(controller.view_paths.map(&:to_s)).to match_paths 'app/views', 'app/legacy_views', 'app/others', 'app/more_views'
140+
end
141+
136142
def match_paths(*paths)
137143
eq paths.map { |path| File.expand_path path }
138144
end

0 commit comments

Comments
 (0)