You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After running controller tests, every controller test fails immediately with:
Failure/Error: raise TypeError, "#{path.inspect} is not a valid path: must be a String, Pathname, or Resolver"
TypeError:
#<RSpec::Rails::ViewRendering::EmptyTemplateResolver::ResolverDecorator:0x00007fee250ed038 @resolver=#<ActionView::FileSystemResolver:0x00007fee3763a740 @unbound_templates=#<Concurrent::Map:0x00007fee3763a718 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x00007fee3763a6a0>, @path="/Users/.../app/views"
>> is not a valid path: must be a String, Pathname, or Resolver
# /Users/../bundler/gems/rails-3025eaa09154/actionview/lib/action_view/path_set.rb:74:in `block in typecast'
# /Users/../bundler/gems/rails-3025eaa09154/actionview/lib/action_view/path_set.rb:67:in `map'
# /Users/../bundler/gems/rails-3025eaa09154/actionview/lib/action_view/path_set.rb:67:in `typecast'
# /Users/../bundler/gems/rails-3025eaa09154/actionview/lib/action_view/path_set.rb:19:in `initialize'
# /Users/../bundler/gems/rails-3025eaa09154/actionview/lib/action_view/view_paths.rb:62:in `new'
# /Users/../bundler/gems/rails-3025eaa09154/actionview/lib/action_view/view_paths.rb:62:in `view_paths='
# /Users/../gems/rspec-rails-4.1.2/lib/rspec/rails/view_rendering.rb:153:in `block (2 levels) in <module:ViewRendering>'
# /Users/../gems/rspec-core-3.12.1/lib/rspec/core/example.rb:457:in `instance_exec'
# /Users/../gems/rspec-core-3.12.1/lib/rspec/core/example.rb:457:in `instance_exec'
# /Users/../gems/rspec-core-3.12.1/lib/rspec/core/hooks.rb:365:in `run'
After investigating, it seems to be that the ActionView::PathSet#typecast method seems to check for class ancestors ("Resolver"), but the RSpec::Rails::ViewRendering::EmptyTemplateResolver::ResolverDecorator of rspec-rails does not fit that bill, so it crashes here.
I've found a workaround by monkey patching the typecast method, e.g. by pasting into spec_helper.rb and adding " RSpec::Rails::ViewRendering::EmptyTemplateResolver::ResolverDecorator" to the case-when clause:
moduleControllerViewPatchextendActiveSupport::Concernincludeddodeftypecast(paths)paths.mapdo |path|
casepathwhenPathname,StringActionView::PathRegistry.file_system_resolver(path.to_s)whenActionView::Resolver,RSpec::Rails::ViewRendering::EmptyTemplateResolver::ResolverDecoratorpathelseraiseTypeError,"#{path.inspect} is not a valid path: must be a String, Pathname, or Resolver"endendendendendrequire'action_view/path_set'ActionView::PathSet.include(ControllerViewPatch)
The text was updated successfully, but these errors were encountered:
@JonRowe thanks for the tip, I had a version constraint in a deeper dep on rspec-rails, that's why I didn't pull the newest rspec-rails when upgrading rails..
Sorry for the distraction :)
What Ruby, Rails and RSpec versions are you using?
Ruby version: 2.7, 3.0
Rails version: 7.1.alpha1 (git main branch)
RSpec version: core: 3.12.1,, rspec-rails 4.1.2
Observed behaviour
After running controller tests, every controller test fails immediately with:
After investigating, it seems to be that the ActionView::PathSet#typecast method seems to check for class ancestors ("Resolver"), but the
RSpec::Rails::ViewRendering::EmptyTemplateResolver::ResolverDecorator
of rspec-rails does not fit that bill, so it crashes here.I've found a workaround by monkey patching the typecast method, e.g. by pasting into spec_helper.rb and adding " RSpec::Rails::ViewRendering::EmptyTemplateResolver::ResolverDecorator" to the case-when clause:
The text was updated successfully, but these errors were encountered: