Skip to content

Commit

Permalink
Generator for Avo
Browse files Browse the repository at this point in the history
  • Loading branch information
coolprobn committed May 31, 2024
1 parent 0173353 commit 7846b59
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Adds VCR generator. ([@TheZero0-ctrl][])
* Adds Pronto Generator with Gihub Action. ([@TheZero0-ctrl][])
* Adds Doorkeeper Generator with Devise. ([@TheZero0-ctrl][])
* Adds Avo generator. ([@mausamp][])

## 0.13.0 (March 26th, 2024)
* Adds Letter Opener generator. ([@coolprobn][])
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ The boring generator introduces following generators:
- Install Webmock: `rails generate boring:webmock:install --app_test_framework=<test_framework>`
- Install Sentry: `rails generate boring:sentry:install --use_env_variable --breadcrumbs_logger=<breadcrumbs_logger_options>`
- Install Pronto with Gitlab CI: `rails generate boring:pronto:gitlab_ci:install`
- Install Pronto with Github Action: `rails generate boring:pronto:github_action:install`
- Install Rack Mini Profiler: `rails generate boring:rack_mini_profiler:install`
- Install VCR: `rails generate boring:vcr:install --testing_framework=<testing_framework> --stubbing_libraries=<stubbing_libraries>`
- Install Pronto with Github Action: `rails generate boring:pronto:github_action:install`
- Install Avo: `rails generate boring:avo:install`
- Install Doorkeeper with devise: `rails generate boring:devise:doorkeeper:install`

## Screencasts
Expand Down
25 changes: 25 additions & 0 deletions lib/generators/boring/avo/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Boring
module Avo
class InstallGenerator < Rails::Generators::Base
desc 'Adds Avo to the application'

def add_avo_gem
say 'Adding Avo gem', :green

Bundler.with_unbundled_env do
run 'bundle add avo'
end
end

def configure_avo
say 'Setting up Avo', :green

Bundler.with_unbundled_env do
run 'bundle exec rails generate avo:install'
end
end
end
end
end
33 changes: 33 additions & 0 deletions test/generators/avo_install_generator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string-literal: true

require 'test_helper'
require 'generators/boring/avo/install/install_generator'

class AvoInstallGeneratorTest < Rails::Generators::TestCase
tests Boring::Avo::InstallGenerator
setup :build_app
teardown :teardown_app

include GeneratorHelper

def destination_root
app_path
end

def test_should_configure_avo_gem
Dir.chdir(app_path) do
quietly { run_generator }

assert_gem 'avo'

assert_file 'config/initializers/avo.rb' do |content|
assert_match(/Avo.configure do |config|/, content)
assert_match(/config.root_path = '\/avo'/, content)
end

assert_file 'config/routes.rb' do |content|
assert_match(/mount Avo::Engine, at: Avo.configuration.root_path/, content)
end
end
end
end

0 comments on commit 7846b59

Please sign in to comment.