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 Accessibility tooling Generator #1105

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ And testing gems like:
* [Capybara](https://github.com/jnicklas/capybara) and
[Google Chromedriver]
integration testing
* [capybara_accessibility_audit](https://github.com/thoughtbot/capybara_accessibility_audit) and
[capybara_accessible_selectors](https://github.com/citizensadvice/capybara_accessible_selectors)
* [Factory Bot](https://github.com/thoughtbot/factory_bot) for test data
* [Formulaic](https://github.com/thoughtbot/formulaic) for integration testing
HTML forms
Expand Down
1 change: 1 addition & 0 deletions lib/suspenders.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "suspenders/version"
require "suspenders/exit_on_failure"
require "suspenders/generators/accessibility_generator"
require "suspenders/generators/advisories_generator"
require "suspenders/generators/app_generator"
require "suspenders/generators/static_generator"
Expand Down
12 changes: 12 additions & 0 deletions lib/suspenders/generators/accessibility_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require_relative "base"

module Suspenders
class AccessibilityGenerator < Generators::Base
Copy link
Contributor

@thiagoa thiagoa Sep 1, 2022

Choose a reason for hiding this comment

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

@seanpdoyle Should we hook up this generator to app_generator.rb?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I think that's a good idea. Where could we add test coverage for that behavior?

Copy link
Contributor

@thiagoa thiagoa Sep 1, 2022

Choose a reason for hiding this comment

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

This should probably be tested at the system level here. This spec file works with a before(:all) hook, so it's not that expensive to add a new example.

def capybara_gems
gem "capybara_accessibility_audit", group: [:test]
gem "capybara_accessible_selectors", group: [:test],
github: "citizensadvice/capybara_accessible_selectors"
Bundler.with_unbundled_env { run "bundle install" }
end
end
end
38 changes: 38 additions & 0 deletions spec/suspenders/generators/accessibility_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require "spec_helper"

RSpec.describe Suspenders::AccessibilityGenerator, type: :generator do
describe "invoke" do
it "bundles the capybara_accessibility_audit gem" do
with_fake_app do
invoke! Suspenders::AccessibilityGenerator

expect("Gemfile")
.to have_bundled("install").matching(/capybara_accessibility_audit/)
.and have_no_syntax_error
end
end

it "bundles the citizensadvice/capybara_accessible_selectors GitHub repository gem" do
with_fake_app do
invoke! Suspenders::AccessibilityGenerator

expect("Gemfile")
.to have_bundled("install").matching(/capybara_accessible_selectors/)
.and have_no_syntax_error
end
end
end

describe "revoke" do
it "removes the gems from Gemfile" do
with_fake_app do
invoke_then_revoke! Suspenders::AccessibilityGenerator

expect("Gemfile")
.to have_no_syntax_error
.and match_original_file
.and not_have_bundled
end
end
end
end