Skip to content

Skipping controller test in a config-based before hook corrupts view paths #2602

Open
@knarewski

Description

@knarewski

What Ruby, Rails and RSpec versions are you using?

Ruby version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
Rails version: 7.0.3
RSpec version:

RSpec 3.11
  - rspec-core 3.11.0
  - rspec-expectations 3.11.0
  - rspec-mocks 3.11.1
  - rspec-rails 5.1.2
  - rspec-support 3.11.0

Observed behaviour

When:

  • having two controller tests of the same controller
  • both tests are invoked
  • a config-based before hook happens to call skip for the first test

Then:

  • The second test fails, unable to find a view
image

When running the failing test independently, it passes:

image

Expected behaviour

In both scenarios the second test should pass, or at least behave consistently

Can you provide an example app?

Commands to run are included in repo's README.md

What I discovered

  • by adding some debugging statements to ActionView::ViewPaths I confirmed that paths are set to empty array for the failing scenario
  • by following the backtrace I discovered that the RSpec::Rails::ViewRendering may be involved and that enabling render_views can be used as a workaround

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions