Skip to content

Commit

Permalink
Merge pull request #107 from TruemarkDev/generator-for-rack-mini-prof…
Browse files Browse the repository at this point in the history
…iler

Generator for rack mini profiler
  • Loading branch information
abhaynikam authored May 16, 2024
2 parents fe51b71 + 91435b1 commit e3fc12d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## master (unreleased)
* Adds Rack Mini Profiler generator. ([@mausamp][])

## 0.13.0 (March 26th, 2024)
* Adds Letter Opener generator. ([@coolprobn][])
Expand Down Expand Up @@ -84,3 +85,4 @@
[@luathn]: https://github.com/luathn
[@coolprobn]: https://github.com/coolprobn
[@aadil]: https://github.com/AdilRT
[@mausamp]: https://github.com/mausamp
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The boring generator introduces following generators:
- Install Whenever: `rails generate boring:whenever:install`
- Install Rswag: `rails generate boring:rswag:install --rails_port=<rails_app_port> --authentication_type=<api_authentication_type> --skip_api_authentication=<skip_api_authentication> --api_authentication_options=<api_authentication_options> --enable_swagger_ui_authentication=<enable_swagger_ui_authentication>`
- Install Webmock: `rails generate boring:webmock:install --app_test_framework=<test_framework>`
- Install Rack Mini Profiler: `rails generate boring:rack_mini_profiler:install`

## Screencasts

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

module Boring
module RackMiniProfiler
class InstallGenerator < Rails::Generators::Base
desc 'Adds rack mini profiler to the application'

def add_rack_mini_profiler_gem
say 'Adding rack mini profiler gem', :green

gem 'rack-mini-profiler', require: false

Bundler.with_unbundled_env do
run 'bundle install'
end
end

def configure_rack_mini_profiler
say 'Configuring rack mini profiler', :green

Bundler.with_unbundled_env do
run 'bundle exec rails g rack_mini_profiler:install'
end
end
end
end
end
31 changes: 31 additions & 0 deletions test/generators/rack_mini_profiler_install_generator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

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

class RackMiniProfilerGeneratorTest < Rails::Generators::TestCase
tests Boring::RackMiniProfiler::InstallGenerator
setup :build_app
teardown :teardown_app

include GeneratorHelper

def destination_root
app_path
end

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

assert_file 'Gemfile' do |content|
assert_match(/gem 'rack-mini-profiler', require: false/, content)
end

assert_file 'config/initializers/rack_mini_profiler.rb' do |content|
assert_match(/if Rails\.env\.development\?/, content)
assert_match(/Rack::MiniProfilerRails.initialize!\(Rails.application\)/, content)
end
end
end
end

0 comments on commit e3fc12d

Please sign in to comment.