Closed
Description
What Ruby, Rails and RSpec versions are you using?
Ruby version: 2.7.2
Rails version: 6.1.3.1
RSpec-core version: 3.10.1
Rspec-rails version: 5.0.1
Rails API
Observed behaviour
When is generated a namespace model with scaffold
rails g scaffold accounts/user name:string
The generator creates wrong variable in request url , example:
describe "GET /show" do
it "renders a successful response" do
user = Accounts::User.create! valid_attributes
get accounts_user_url(accounts_user), as: :json
expect(response).to be_successful
end
end
Expected behaviour
Same variable name when create spec data and request url
OPTION 1
describe "GET /show" do
it "renders a successful response" do
user = Accounts::User.create! valid_attributes
get accounts_user_url(user), as: :json
expect(response).to be_successful
end
end
or
OPTION 2
describe "GET /show" do
it "renders a successful response" do
accounts_user = Accounts::User.create! valid_attributes
get accounts_user_url(accounts_user), as: :json
expect(response).to be_successful
end
end
Solution
The main problem is the method show_helper uses table_names to build request url, while the spec variable data uses file_name
I recon the first option is better to keep the pattern of another templates and i would like to create a PR to this fix
Metadata
Metadata
Assignees
Labels
No labels