Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new RSpec/MultipleTestTargetsPerSpecFile cop #1699

Closed
wants to merge 1 commit into from
Closed

Conversation

ydah
Copy link
Member

@ydah ydah commented Aug 16, 2023

Resolve: #1691


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

If you have created a new cop:

  • Added the new cop to config/default.yml.
  • The cop is configured as Enabled: pending in config/default.yml.
  • The cop is configured as Enabled: true in .rubocop.yml.
  • The cop documents examples of good and bad code.
  • The tests assert both that bad code is reported and that good code is not reported.
  • Set VersionAdded: "<<next>>" in default/config.yml.

@pirj
Copy link
Member

pirj commented Aug 21, 2023

/Users/pirj/source/real-world-rspec/sharetribe/spec/services/util_spec.rb:44:1: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
describe StringUtils do
^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/sharetribe/spec/services/util_spec.rb:66:1: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
describe ArrayUtils do
^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/sharetribe/spec/services/result.rb:78:3: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
  describe Result::Success do
  ^^^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/sharetribe/spec/services/result.rb:173:3: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
  describe Result::Error do
  ^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/sharetribe/spec/controllers/application_controller_spec.rb:154:1: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
describe ApplicationController, type: :controller do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/sharetribe/spec/controllers/application_controller_spec.rb:238:1: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
describe ApplicationController, type: :controller do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/sharetribe/spec/controllers/application_controller_spec.rb:256:1: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
describe ApplicationController, type: :controller do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/rspec-mocks/spec/rspec/mocks/matchers/have_received_spec.rb:665:5: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
    RSpec.describe Matchers::HaveReceived, "when used in a context that has rspec-mocks and rspec-expectations available" do
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/rspec-mocks/spec/rspec/mocks/matchers/have_received_spec.rb:675:5: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
    RSpec.describe Matchers::HaveReceived, "when used in a context that has only rspec-mocks available" do
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/rspec-expectations/spec/rspec/matchers/built_in/change_spec.rb:1036:1: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
RSpec.describe RSpec::Matchers::BuiltIn::Change do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/pirj/source/real-world-rspec/rspec-expectations/spec/rspec/matchers/built_in/change_spec.rb:1058:1: C: RSpec/MultipleTestTargetsPerSpecFile: Spec files should only include one test target object.
RSpec.describe RSpec::Matchers::BuiltIn::ChangeRelatively do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

At a glance, there are a few false positives, and it feels that the cop should be more permissive.

@ydah
Copy link
Member Author

ydah commented Feb 29, 2024

Now I'm rethinking whether I really need this Cop.
As mentioned in the comments below, it may not be extracted to a separate file for smaller internal classes, and since there is no similar cop on the rubocop/rubocop side, it does not make sense that this cop exists only on the RuboCop RSpec side. So I decided to close this PR.

@ydah ydah closed this Feb 29, 2024
@pirj pirj deleted the add/1691 branch February 29, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cop idea: Move nested modules to separate specs
2 participants