It wrong variable name with namepace prefix in the view specs, when is generated a namespace & model-name with scaffold.
$ rails g scaffold admin/user name:string --model-name=User
# spec/views/admin/posts/show.html.slim_spec.rb
RSpec.describe "admin/posts/show", type: :view do
before(:each) do
assign(:admin_post, User.create!())
end
...
end
# spec/views/admin/posts/new.html.slim_spec.rb
RSpec.describe "admin/posts/new", type: :view do
before(:each) do
assign(:admin_post, User.new())
end
...
end
# spec/views/admin/posts/edit.html.slim_spec.rb
RSpec.describe "admin/posts/edit", type: :view do
let(:admin_post) {
User.create!()
}
before(:each) do
assign(:admin_post, admin_post)
end
it "renders the edit admin_post form" do
render
assert_select "form[action=?][method=?]", admin_post_path(admin_post), "post" do
end
end
Expected behaviour
It is expected that the generated code is below.
# spec/views/admin/posts/show.html.slim_spec.rb
RSpec.describe "admin/posts/show", type: :view do
before(:each) do
assign(:post, User.create!())
end
...
end
# spec/views/admin/posts/new.html.slim_spec.rb
RSpec.describe "admin/posts/new", type: :view do
before(:each) do
assign(:post, User.new())
end
...
end
# spec/views/admin/posts/edit.html.slim_spec.rb
RSpec.describe "admin/posts/edit", type: :view do
let(:post) {
User.create!()
}
before(:each) do
assign(:post, post)
end
it "renders the edit admin_post form" do
render
assert_select "form[action=?][method=?]", admin_post_path(post), "post" do
end
end
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.2.2 Rails version: 7.0.8 RSpec version: 3.12
Observed behaviour
It wrong variable name with namepace prefix in the view specs, when is generated a namespace & model-name with scaffold.
Expected behaviour
It is expected that the generated code is below.
Can you provide an example app?
https://github.com/taketo1113/rails-sample-rspec-rails/tree/view-spec-model-name