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

Rubocop rspec #4660

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Rubocop rspec #4660

wants to merge 18 commits into from

Conversation

KludgeKML
Copy link
Contributor

What

Turn on rails and rspec rubocops, and make current rspec code compliant with the new cops.

Why

Currently we're only using the default config file for govuk-rubocop, but we have an rspec test suite and this is technically a rails app since it's an engine, so we should be using the extended configurations for rails and rspec.

Visual Changes

No visual changes.

- the component gem isn't a rails app, but has rails
  features since it's an engine, and we're using
  rspec as our test runner, so we should try to
  adhere to our rubocop-enforced style for that.
- run rubocop -A
- since these are unsafe, they have been checked
  manually more thoroughly. They all seem to be
  reasonable.
- visible false finds hidden and invisible elements, it's
  fairly clear from the contexts here that :hidden is
  actually what's wanted.
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4660 February 27, 2025 14:50 Inactive
- these two are fairly simple, it just wants expectations
  rather than raw asserts, so re-write
- There was genuinely no expectation in this example,
  I believe it's testing for console messages but not
  sure, a frontender could check this.
- It's not clear whether this test is actually testing
  anything, or if it's to run the visual regressions
  for other purposes. To confirm with a frontender.
- these are all just presenters, so should be in the
  presenter path. We lose a bit of context maybe,
  so frontenders should confirm this is okay.
- To look at. Are these testing the right thing?
- since we can safely nest the capybara based
  tests for Radio inside the top describe, do that.
- this is clearly a copy-pasto, the second describe group's
  examples are all about title rather than target.
- these are gnarly problems, outside of the scope of this
  PR to fix, so disable them.
- feedback arguably shouldn't be using request as an
  object inside the component (the path info should be
  passed to it, which would allow this to be tested without
  the allow_any_instance_of.) But this is the current
  behaviour, so we live with it for now.
- layout_for_admin wants us to peer inside ActionView::Base.
  There's some discussion of why this is here:
  5ba7778

  ...and here:

#3993 (comment)
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.

2 participants