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

Introduce suspenders:accessibility generator #1137

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

stevepolitodesign
Copy link
Contributor

@stevepolitodesign stevepolitodesign commented Oct 31, 2023

Introduce suspenders:accessibility generator

Ported over from #1105

Installs capybara_accessibility_audit and
capybara_accessible_selectors.

./bin/rails g suspenders:accessibility

Introduces Suspenders::Generators::APIAppUnsupported module for
generators that cannot be run in an API only application.

This uses a concern to ensure we raise an error before the generator
including the module invokes any of its methods.

How to manually review this pull-request

If you want to manually run this generator, simply do the following:

  1. cd test/dummy
  2. touch Gemfile
  3. ./bin/rails g suspenders:accessibility

Confirm the Gemfile and Gemfile.lock contains the gems.

To test that it won't work on an API only application, comment out or remove
config.api_only = true from test/dummy/config/application.rb and run the
steps above

@stevepolitodesign stevepolitodesign changed the base branch from main to suspenders-3-0-0 October 31, 2023 11:53
@stevepolitodesign stevepolitodesign marked this pull request as ready for review October 31, 2023 11:54
@stevepolitodesign stevepolitodesign changed the title Introduce suspenders:accessibility_generator Introduce suspenders:accessibility generator` Oct 31, 2023
@stevepolitodesign stevepolitodesign changed the title Introduce suspenders:accessibility generator` Introduce suspenders:accessibility generator Oct 31, 2023
@stevepolitodesign

This comment was marked as resolved.

@stevepolitodesign stevepolitodesign force-pushed the accessibility-generator branch 2 times, most recently from c4c8ccc to 8a59f7f Compare November 3, 2023 12:09
Comment on lines +14 to +20
included do
def raise_if_api_only_app
if api_only_app?
raise Suspenders::Generators::APIAppUnsupported::Error
end
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will run first when we call include Suspenders::Generators::APIAppUnsupported in a generator. This is important because we don't want to invoke any of the generator's methods.

Ported over from #1105

Installs [capybara_accessibility_audit] and
[capybara_accessible_selectors].

`./bin/rails g suspenders:accessibility`

Introduces `Suspenders::Generators::APIAppUnsupported` module for
generators that cannot be run in an [API only][] application.

This uses a [concern][] to ensure we raise an error before the generator
including the module invokes any of its methods.

[capybara_accessibility_audit]: https://github.com/thoughtbot/capybara_accessibility_audit
[capybara_accessible_selectors]: https://github.com/citizensadvice/capybara_accessible_selectors
[API only]: https://guides.rubyonrails.org/api_app.html
[concern]: https://api.rubyonrails.org/classes/ActiveSupport/Concern.html
@stevepolitodesign stevepolitodesign merged commit 5a6b6e4 into suspenders-3-0-0 Nov 3, 2023
2 checks passed
@stevepolitodesign stevepolitodesign deleted the accessibility-generator branch November 3, 2023 19:37
@stevepolitodesign stevepolitodesign mentioned this pull request Nov 9, 2023
17 tasks
stevepolitodesign added a commit that referenced this pull request May 10, 2024
Ported over from #1105

Installs [capybara_accessibility_audit] and
[capybara_accessible_selectors].

`./bin/rails g suspenders:accessibility`

Introduces `Suspenders::Generators::APIAppUnsupported` module for
generators that cannot be run in an [API only][] application.

This uses a [concern][] to ensure we raise an error before the generator
including the module invokes any of its methods.

[capybara_accessibility_audit]: https://github.com/thoughtbot/capybara_accessibility_audit
[capybara_accessible_selectors]: https://github.com/citizensadvice/capybara_accessible_selectors
[API only]: https://guides.rubyonrails.org/api_app.html
[concern]: https://api.rubyonrails.org/classes/ActiveSupport/Concern.html
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