rubocop-rspec
rubocop-rspec copied to clipboard
FilePath deficiencies
- https://github.com/rubocop/rubocop-rspec/pull/1698#discussion_r1296729996 Would it detect:
RSpec.describe 'MyClass' do
RSpec.describe ::MyClass do
- https://github.com/rubocop/rubocop-rspec/pull/1698#discussion_r1296733977 refactor to avoid nested loops?
In the following case, I often use rspec-request_describer to write a request spec. So in the case of String, I don't think it will necessarily match the file path. WDYT? Is there a way to know that in the case of string, it always indicates Class?
RSpec.describe 'MyClass' do
Why? It could be /get_users_spec.rb as per request_descriptor naming schema, even with dynamic parts. Or /widget_management_spec.rb if you follow the example naming from rspec-rails examples http://rspec.info/features/6-1/rspec-rails/request-specs/request-spec/
I like it more descriptive and human-readable, with explicit URL defined in ‘def request’ or subject
.
And i don’t see why the file name should not match the top-level docstring.
rspec-request_describer is a plugin for RSpec, but it is useful to use it as follows, but if you use such a plug-in, it may not be a big problem because Exclude will not change the behavior in the first place before and after the change
# `RSpec::RequestDescriber` provides `subject` from its top-level description.
# subject will be `get('/users')`.
RSpec.describe 'GET /users' do
it 'returns 200' do
subject
expect(response).to have_http_status(200)
end
end