Skip to content

Commit

Permalink
KBP-121 #time 1h implement cli helper specs
Browse files Browse the repository at this point in the history
  • Loading branch information
İsmail Akbudak committed Sep 11, 2017
1 parent e87c3d5 commit 95f9a5c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ Metrics/BlockLength:

Style/FrozenStringLiteralComment:
EnforcedStyle: when_needed

Style/IndentHeredoc:
Exclude:
- 'spec/features/cli_help_spec.rb'
12 changes: 12 additions & 0 deletions USAGE
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions spec/features/cli_help_spec.rb
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions spec/support/cybele_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 95f9a5c

Please sign in to comment.