diff --git a/.rubocop.yml b/.rubocop.yml index 10342ae..d7f20d3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -34,3 +34,7 @@ Metrics/BlockLength: Style/FrozenStringLiteralComment: EnforcedStyle: when_needed + +Style/IndentHeredoc: + Exclude: + - 'spec/features/cli_help_spec.rb' diff --git a/USAGE b/USAGE new file mode 100644 index 0000000..69ca295 --- /dev/null +++ b/USAGE @@ -0,0 +1,12 @@ +Description: + Cybele is a Rails template with Lab2023 standard + defaults. + + For full details check our GitHub project: + https://github.com/kebab-project/cybele + +Example: + cybele ~/Workplace/blog + + This generates a Rails installation in ~/Workplace/blog configured + with our preferred defaults. diff --git a/lib/cybele/generators/app_generator.rb b/lib/cybele/generators/app_generator.rb index 6a1de43..9ce6784 100644 --- a/lib/cybele/generators/app_generator.rb +++ b/lib/cybele/generators/app_generator.rb @@ -98,6 +98,10 @@ def goodbye say 'Congratulations! That\'s all...', :green end + def self.banner + "cybele #{arguments.map(&:usage).join(' ')} [options]" + end + protected def get_builder_class diff --git a/spec/features/cli_help_spec.rb b/spec/features/cli_help_spec.rb new file mode 100644 index 0000000..4bd3c54 --- /dev/null +++ b/spec/features/cli_help_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Command line help output' do + let(:help_text) { cybele_help_command } + + it 'does not contain the default rails usage statement' do + expect(help_text).not_to include('rails new APP_PATH [options]') + end + + it 'provides the correct usage statement for cybele' do + expect(help_text).to include <<~EOH + Usage: + cybele APP_PATH [options] + EOH + end + + it 'does not contain the default rails group' do + expect(help_text).not_to include('Rails options:') + end + + it 'provides help and version usage within the cybele group' do + expect(help_text).to include <<~EOH +Cybele options: + -h, [--help], [--no-help] # Show cybele help message and quit + -v, [--version], [--no-version] # Show cybele version number and quit + [--skip-ask], [--no-skip-ask] # Skip ask for cybele options. Default: skip + # Default: true + [--skip-create-database], [--no-skip-create-database] # Skip create database. Default: don't skip + [--skip-sidekiq], [--no-skip-sidekiq] # Skip sidekiq integration. Default: don't skip +EOH + end + + it 'does not show the default extended rails help section' do + expect(help_text).not_to include('Create cybele files for app generator.') + end + + it 'contains the usage statement from the cybele gem' do + expect(help_text).to include IO.read(usage_file) + end +end diff --git a/spec/features/new_not_default_project_spec.rb b/spec/features/new_not_default_project_spec.rb index eb5036f..1cea4ec 100644 --- a/spec/features/new_not_default_project_spec.rb +++ b/spec/features/new_not_default_project_spec.rb @@ -38,4 +38,23 @@ expect(routes_file).not_to match("^require 'sidekiq/web'") expect(routes_file).not_to match("^require 'sidekiq/cron/web'") end + + it 'uses responders' do + gemfile_file = content('Gemfile') + expect(gemfile_file).to match(/^gem 'responders'/) + + lib_file = content('lib/application_responder.rb') + expect(lib_file).to match(/^class ApplicationResponder/) + + controller_file = content('app/controllers/application_controller.rb') + expect(controller_file).to match("^require 'application_responder'") + expect(controller_file).to match('self.responder = ApplicationResponder') + expect(controller_file).to match('respond_to :html, :js, :json') + + locale_file = content('config/locales/responders.en.yml') + expect(locale_file).not_to match('# alert:') + expect(locale_file).to match('create:') + expect(locale_file).to match('update:') + expect(locale_file).to match('destroy:') + end end diff --git a/spec/support/cybele_test_helpers.rb b/spec/support/cybele_test_helpers.rb index 080aee8..3102b97 100644 --- a/spec/support/cybele_test_helpers.rb +++ b/spec/support/cybele_test_helpers.rb @@ -67,6 +67,10 @@ def drop_dummy_database end end + def usage_file + @usage_path ||= File.join(root_path, 'USAGE') + end + private def tmp_path