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
Hi! We are trying to use the latest version of rspec-rails. When requiring RSpec::Rails::ViewExampleGroup::ExampleMethods to use stub_template, we are seeing the following error:
1) Foo does something
Failure/Error: stub_template('test/test_email.html.erb' => '<h1>Test email!</h1>')
NameError:
undefined local variable or method `controller' for #<RSpec::ExampleGroups::Foo "does something" (./emails/spec/testing_spec.rb:11)>
# ./packs/emails/spec/testing_spec.rb:8:in `block (2 levels) in <main>'
# -e:1:in `<main>'
Expected behaviour
I would expect stub_template to work. I believe the changes in this PR caused the issue: #2714
👋 Please use the public api include ::RSpec::Rails::ViewExampleGroup or include via tags which is the preferred method. RSpec.describe "Something", type: :view.
You'll notice that in the view there are several things in view specs that depend on controller as a method because thats how Rails does things internally, by bringing in only the DSL module, you're skipping all the setup that makes it work,
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.2
Rails version: 7.0
RSpec version: 6.1.0 (latest)
Observed behaviour
Hi! We are trying to use the latest version of rspec-rails. When requiring
RSpec::Rails::ViewExampleGroup::ExampleMethods
to usestub_template
, we are seeing the following error:Expected behaviour
I would expect stub_template to work. I believe the changes in this PR caused the issue: #2714
Can you provide an example reproduction?
Yep! This is the code to reproduce the error:
The text was updated successfully, but these errors were encountered: