Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
knarewski opened this issue May 25, 2022 · 1 comment

Comments

@knarewski
Copy link

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
@JonRowe
Copy link
Member

JonRowe commented May 25, 2022

Whats weird is this only happens when you define the hook in config, if you do it in the example group itself it works as expected, similarly if you skip directly in the example. This suggests that prehaps the hook ordering is somehow at fault but I can't see how skipping one example affects the other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants