Skip to content

Failing rspec test when using stub_template with Rails 6.1 #2485

Closed as not planned
@glennakamura

Description

@glennakamura

What Ruby, Rails and RSpec versions are you using?

Ruby version: 3.0.0
Rails version: 6.1.3
RSpec version: 3.10

  • rspec-core 3.10.1
  • rspec-expectations 3.10.1
  • rspec-mocks 3.10.2
  • rspec-rails 5.0.0
  • rspec-support 3.10.2

Observed behaviour

Tests using a previously stubbed template fail if another test clears the view cache.

$ bundle exec rspec
..F

Failures:

  1) stub.html.erb renders stub again
     Failure/Error: render
     
     ActionView::Template::Error:
       undefined method `__stub_html_erb___2739773391792524586_14880' for #<ActionView::Base:0x00000000007620>
     # ./spec/views/stub.html.erb_spec.rb:21:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `__stub_html_erb___2739773391792524586_14880' for #<ActionView::Base:0x00000000007620>
     #   ./spec/views/stub.html.erb_spec.rb:21:in `block (2 levels) in <top (required)>'

Finished in 0.05772 seconds (files took 0.69206 seconds to load)
3 examples, 1 failure

Failed examples:

rspec ./spec/views/stub.html.erb_spec.rb:20 # stub.html.erb renders stub again

Expected behaviour

All tests pass. (works with Rails 6.0)

Can you provide an example app?

Example app: https://github.com/glennakamura/rspec_stub_template_failure.git
Expect bundle exec rspec to pass but fails with Rails 6.1

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