Skip to content

Commit

Permalink
Introduce Accessibility tooling Generator
Browse files Browse the repository at this point in the history
Create the `Suspenders::AccessibilityGenerator` to install
[capybara_accessibility_audit][] and [capybara_accessible_selectors][].

[capybara_accessibility_audit]: https://github.com/thoughtbot/capybara_accessibility_audit
[capybara_accessible_selectors]: https://github.com/citizensadvice/capybara_accessible_selectors
  • Loading branch information
seanpdoyle committed Aug 25, 2022
1 parent 52f9787 commit d0a53ec
Showing 4 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
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"
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
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

0 comments on commit d0a53ec

Please sign in to comment.