Skip to content

chore(specs): drop redundant type metadata - #2959

Merged
mroderick merged 2 commits into
codebar:masterfrom
ankuanku1:chore/remove-redundant-spec-type-metadata
Sep 28, 2026
Merged

mroderick merged 2 commits into
codebar:masterfrom
ankuanku1:chore/remove-redundant-spec-type-metadata

Conversation

@ankuanku1

Copy link
Copy Markdown
Contributor

Closes #2934

infer_spec_type_from_file_location! doesn't cover spec/services, spec/presenters or spec/lib/tasks, so not all of the type: metadata in these specs was redundant. Removing type: :task breaks the rake specs, because TaskExampleGroup (which defines task) is only included for that type. spec/support/rake_tasks.rb was meant to add the tag automatically, but it matched %r{/spec/tasks/}, a folder that didn't exist. This changes it to %r{/spec/lib/tasks/} and drops the type: from all 12 specs listed in the issue.

RuboCop's RSpec/DescribeClass only allows a string describe when it can see a type like type: :task in the file, and it can't see tags that RSpec assigns from the path. So spec/lib/tasks/**/* is now excluded from that cop in .rubocop.yml. workshop_presenter_capacity_spec.rb was a string tagged type: :model. It now uses describe WorkshopPresenter and described_class, the same as workshop_presenter_spec.rb. Nothing uses :service, so the service specs behave the same.

Testing

  • bundle exec parallel_rspec spec/ -n 3: 1552 examples, 0 failures
  • bundle exec rspec spec/lib/tasks --dry-run --tag type:task: all 18 rake examples selected (the tag now comes from the path)
  • bundle exec rubocop: no offenses

…metadata

rake_tasks.rb matched spec/tasks/, which has never existed, so rake specs had to set type: :task by hand. Point it at spec/lib/tasks/ and remove the explicit type: from the 12 specs in codebar#2934. Exclude spec/lib/tasks from RSpec/DescribeClass, since RuboCop cannot see path-derived metadata, and describe WorkshopPresenter by class instead of tagging it type: :model.

@mroderick mroderick left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified in a worktree of the PR branch:

  • The root cause is real: spec/support/rake_tasks.rb tagged files via %r{/spec/tasks/}, a directory that doesn't exist; the rake specs live in spec/lib/tasks/ and only got type: :task from their explicit per-file tags. The fix points the derived metadata at the real path, and config.include TaskExampleGroup, type: :task is the only type: consumer in the support stack.
  • The other tag removals are safe: infer_spec_type_from_file_location! has no mappings for spec/services, spec/presenters, or spec/lib/tasks, and nothing includes an example group for :service. All 12 files listed in #2934 match the changed spec files.
  • workshop_presenter_capacity_spec.rb now matches its sibling workshop_presenter_spec.rb (class describe + described_class), which was already written that way.
  • The RSpec/DescribeClass exclusion is scoped to spec/lib/tasks/**/* only.
  • Ran from the worktree: full parallel_rspec spec/ -n 3 — 1552 examples, 0 failures; rspec spec/lib/tasks --dry-run --tag type:task — all 18 rake examples selected via the path-derived tag; full rubocop — 436 files, no offenses.

@mroderick
mroderick enabled auto-merge September 28, 2026 06:28
@mroderick
mroderick merged commit f09eca6 into codebar:master Sep 28, 2026
10 checks passed
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.

Remove redundant explicit RSpec type: metadata from specs

2 participants