Skip to content

Commit

Permalink
Code refactor for test specs and change sidekiq_redis environment key
Browse files Browse the repository at this point in the history
  • Loading branch information
İsmail Akbudak committed Dec 21, 2018
1 parent 6b10ade commit e690b25
Show file tree
Hide file tree
Showing 34 changed files with 597 additions and 432 deletions.
108 changes: 14 additions & 94 deletions spec/features/new_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,9 @@
expect(database_file).to match(/^ database: #{app_name}_staging/)
end

it 'uses sidekiq' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match(/^gem 'sidekiq'/)
expect(gemfile_file).to match(/^gem 'sidekiq-cron'/)
expect(gemfile_file).to match(/^gem 'cocaine'/)
expect(gemfile_file).to match(/^gem 'devise-async'/)

sidekiq_file = content('config/sidekiq.yml')
expect(sidekiq_file).to match('[high_priority, 2]')

sidekiq_schedule_file = content('config/sidekiq_schedule.yml')
expect(sidekiq_schedule_file).to match(/-> Daily at midnight/)
it_behaves_like 'uses sidekiq'

initializers_file = content('config/initializers/sidekiq.rb')
expect(initializers_file).to match("^require 'sidekiq'")
expect(initializers_file).to match("^require 'sidekiq/web'")

routes_file = content('config/routes.rb')
expect(routes_file).to match("^require 'sidekiq/web'")
expect(routes_file).to match("^require 'sidekiq/cron/web'")
expect(routes_file).to match(/# ========== Sidekiq ==========/)

rake_file = content('lib/tasks/sidekiq.rake')
expect(rake_file).to match(/^namespace :sidekiq/)
end

it 'uses responders' do
responder_test
end
it_behaves_like 'uses responders'

it 'uses cybele_version' do
expect(File).to exist(file_project_path('VERSION.txt'))
Expand Down Expand Up @@ -127,9 +101,7 @@
expect(show_for_tr_yml_file).to match('show_for')
end

it 'uses config and staging file' do
config_test
end
it_behaves_like 'uses config'

it 'uses recipient_interceptor' do
gemfile_file = content('Gemfile')
Expand All @@ -139,9 +111,7 @@
expect(config_staging_file).to match('RecipientInterceptor.new')
end

it 'uses locale_language' do
locale_language_test
end
it_behaves_like 'uses locale_language'

it 'uses simple_form' do
gemfile_file = content('Gemfile')
Expand All @@ -160,14 +130,9 @@
expect(simple_form_tr_yml_file).to match('simple_form')
end

it 'control .env files' do
dotenv_test
end
it_behaves_like 'has .env files'

it 'uses mailer' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match("gem 'mailtrap'")

expect(File).to exist(file_project_path('config/settings/production.yml'))
expect(File).to exist(file_project_path('config/settings/staging.yml'))

Expand All @@ -194,17 +159,11 @@
expect(locale_file).to match('Bullet')
end

it 'uses devise' do
devise_test
end
it_behaves_like 'uses devise'

it 'uses error_pages' do
error_pages_test
end
it_behaves_like 'uses error_pages'

it 'uses gitignore' do
git_ignore_test
end
it_behaves_like 'uses gitignore'

it 'uses asset files' do
gemfile_file = content('Gemfile')
Expand Down Expand Up @@ -404,53 +363,14 @@
expect(application_mailer).to match('Settings.email.noreply')
end

it 'uses ssl_setting' do
force_ssl_test
end

it 'uses docker development environment' do

file_exist_test(
%w[
docker-compose.yml
Dockerfile
bin/start-app.sh
bin/start-sidekiq.sh
]
)

file_exist_test(
%w[
.env.sample
.env.local
.environments/.env.local
]
) do |env|
file = content(env)
expect(file).to match('REDISTOGO_URL=redis://redis:6379/0')
expect(file).to match('RACK_ENV=development')
expect(file).to match('POSTGRESQL_HOST=postgres')
expect(file).to match('REDIS_HOST=redis')
end
it_behaves_like 'uses ssl_setting'

file_exist_test(
%w[
.environments/.env.staging
.environments/.env.production
]
) do |env|
expect(content(env)).to match('REDISTOGO_URL=')
end
end
it_behaves_like 'uses docker development environment'

it 'uses pronto' do
pronto_test
end

it 'uses guardfile' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match("gem 'guard'")
it_behaves_like 'uses pronto'

expect(File).to exist(file_project_path('Guardfile'))
it 'match readme' do
gemfile_file = content('README.md')
expect(gemfile_file).to match(file_content('README_DEFAULT.md'))
end
end
18 changes: 18 additions & 0 deletions spec/features/new_not_default_no_skip_docker_project_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Create new project without default configuration and no-skip docker' do
before(:all) do
remove_project_directory
run_cybele(cybele_not_default_parameters(no_skips: %w[docker]))
setup_app_dependencies
end

it_behaves_like 'uses docker development environment without sidekiq'

it 'match readme' do
gemfile_file = content('README.md')
expect(gemfile_file).to match(file_content('README_ONLY_NO_SKIP_DOCKER.md'))
end
end
18 changes: 18 additions & 0 deletions spec/features/new_not_default_no_skip_sidekiq_project_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Create new project without default configuration and no-skip sidekiq' do
before(:all) do
remove_project_directory
run_cybele(cybele_not_default_parameters(no_skips: %w[sidekiq]))
setup_app_dependencies
end

it_behaves_like 'uses sidekiq'

it 'match readme' do
gemfile_file = content('README.md')
expect(gemfile_file).to match(file_content('README_ONLY_NO_SKIP_SIDEKIQ.md'))
end
end
51 changes: 14 additions & 37 deletions spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
expect(routes_file).not_to match("^require 'sidekiq/cron/web'")
end

it 'uses responders' do
responder_test
end
it_behaves_like 'uses responders'

it 'uses rollbar' do
gemfile_file = content('Gemfile')
Expand Down Expand Up @@ -115,13 +113,9 @@
)
end

it 'uses config and staging file' do
config_test
end
it_behaves_like 'uses config'

it 'uses locale_language' do
locale_language_test
end
it_behaves_like 'uses locale_language'

it 'uses recipient_interceptor' do
gemfile_file = content('Gemfile')
Expand Down Expand Up @@ -158,14 +152,9 @@
)
end

it 'control .env files' do
dotenv_test
end
it_behaves_like 'has .env files'

it 'uses mailer' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match("gem 'mailtrap'")

file_exist_test(
%w[
config/settings/production.yml
Expand All @@ -188,17 +177,11 @@
expect(File).not_to exist(file_project_path('app/views/layouts/application.html.haml'))
end

it 'uses devise' do
devise_test
end
it_behaves_like 'uses devise'

it 'uses error_pages' do
error_pages_test
end
it_behaves_like 'uses error_pages'

it 'uses gitignore' do
git_ignore_test
end
it_behaves_like 'uses gitignore'

it 'do not use asset files' do
gemfile_file = content('Gemfile')
Expand Down Expand Up @@ -356,9 +339,7 @@
expect(application_mailer).to match('Settings.email.noreply')
end

it 'uses ssl_setting' do
force_ssl_test
end
it_behaves_like 'uses ssl_setting'

it "don't use docker development environment" do
file_not_exist_test(
Expand All @@ -377,7 +358,7 @@
.environments/.env.local
]
) do |env|
expect(content(env)).not_to match('REDISTOGO_URL=redis://redis:6379/0')
expect(content(env)).not_to match('SIDEKIG_REDIS_URL=redis://redis:6379/0')
end

file_exist_test(
Expand All @@ -386,18 +367,14 @@
.environments/.env.production
]
) do |env|
expect(content(env)).not_to match('REDISTOGO_URL=')
expect(content(env)).not_to match('SIDEKIG_REDIS_URL=')
end
end

it 'uses pronto' do
pronto_test
end

it 'uses guardfile' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match("gem 'guard'")
it_behaves_like 'uses pronto'

expect(File).to exist(file_project_path('Guardfile'))
it 'match readme' do
gemfile_file = content('README.md')
expect(gemfile_file).to match(file_content('README_SKIP_ALL.md'))
end
end
39 changes: 39 additions & 0 deletions spec/files/README_DEFAULT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Dummy_app

# TODOs
- Change email sender domain address and basic_auth info in `config/settings.yml`
- Change email sender domain address in `config/initializers/devise.rb`
- Create `.pronto.yml` file from `example.pronto.yml` file

# Infos
- Edit secret keys
➜ ✗ EDITOR=vi bin/rails credentials:edit


# Docker development
- run following commands on terminal
➜ ✗ docker-compose build
➜ ✗ docker-compose run app bundle install
➜ ✗ docker-compose run app bundle exec rails db:create db:migrate db:seed
➜ ✗ docker-compose up
- open in your browser localhost:3000 or lvh.me:3000
- If you want to access rails console run this command before
➜ ✗ docker-compose run app bundle install --binstubs
➜ ✗ docker-compose run app bundle exec rails c

# Local development

- Change SIDEKIG_REDIS_URL and POSTGRESQL_HOST environment in `.env.local` file

- run following commands on terminal
➜ ✗ bundle exec rails server
- open in your browser localhost:3000 or lvh.me:3000

➜ ✗ redis-server
➜ ✗ bundle exec rake sidekiq:start

# Development
➜ ✗ pronto run
➜ ✗ pronto run -r haml
- On feature branch
➜ ✗ pronto run -c origin/develop
36 changes: 36 additions & 0 deletions spec/files/README_ONLY_NO_SKIP_DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Dummy_app

# TODOs
- Change email sender domain address and basic_auth info in `config/settings.yml`
- Change email sender domain address in `config/initializers/devise.rb`
- Create `.pronto.yml` file from `example.pronto.yml` file

# Infos
- Edit secret keys
➜ ✗ EDITOR=vi bin/rails credentials:edit


# Docker development
- run following commands on terminal
➜ ✗ docker-compose build
➜ ✗ docker-compose run app bundle install
➜ ✗ docker-compose run app bundle exec rails db:create db:migrate db:seed
➜ ✗ docker-compose up
- open in your browser localhost:3000 or lvh.me:3000
- If you want to access rails console run this command before
➜ ✗ docker-compose run app bundle install --binstubs
➜ ✗ docker-compose run app bundle exec rails c

# Local development

- Change POSTGRESQL_HOST environment in `.env.local` file

- run following commands on terminal
➜ ✗ bundle exec rails server
- open in your browser localhost:3000 or lvh.me:3000

# Development
➜ ✗ pronto run
➜ ✗ pronto run -r haml
- On feature branch
➜ ✗ pronto run -c origin/develop
Loading

0 comments on commit e690b25

Please sign in to comment.