From c1a306a925cf5ac68ca7720b81ebdd47c84f712e Mon Sep 17 00:00:00 2001 From: "esref.viduslu" Date: Wed, 22 Nov 2017 10:07:55 +0300 Subject: [PATCH] KBP-141 #time 2h - Git and git flow integrated. --- lib/cybele/app_builder.rb | 7 ++++++ lib/cybele/generators/app_generator.rb | 5 ++++ spec/features/git_and_git_flow_spec.rb | 33 ++++++++++++++++++++++++++ spec/support/cybele_test_helpers.rb | 10 ++++++++ 4 files changed, 55 insertions(+) create mode 100644 spec/features/git_and_git_flow_spec.rb diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index 1ba402f..d2b9e84 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -90,6 +90,13 @@ def setup_gitignore_folders end end + def git_and_git_flow_commands + git :init + git flow: 'init -d -f' + git add: '.' + git commit: '-m "Project initialized"' + end + private def configure_environment(rails_env, config) diff --git a/lib/cybele/generators/app_generator.rb b/lib/cybele/generators/app_generator.rb index 9d2ff6c..8d9ed38 100644 --- a/lib/cybele/generators/app_generator.rb +++ b/lib/cybele/generators/app_generator.rb @@ -218,6 +218,11 @@ def configure_error_pages build :configure_error_pages end + def setup_git_and_git_flow + say 'Initialize git' + build :git_and_git_flow_commands + end + def goodbye say 'Congratulations! That\'s all...', :green end diff --git a/spec/features/git_and_git_flow_spec.rb b/spec/features/git_and_git_flow_spec.rb new file mode 100644 index 0000000..d366610 --- /dev/null +++ b/spec/features/git_and_git_flow_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Create new project without default configuration' do + before do + drop_dummy_database + remove_project_directory + run_cybele('--database=sqlite3 --skip-create-database --skip-sidekiq --skip-simple-form --skip-show-for'\ + ' --skip-haml') + setup_app_dependencies + end + + let(:git_branch) { cybele_help_run(command: "git branch") } + + + it 'git branch test' do + expect(git_branch).to include <<~EOH + * develop + master + EOH + end + + it 'git flow test' do + cybele_help_run(command: "git flow feature start test") + git_flow = cybele_help_run(command: "git branch") + expect(git_flow).to include <<~EOH + develop + * feature/test + master + EOH + end +end diff --git a/spec/support/cybele_test_helpers.rb b/spec/support/cybele_test_helpers.rb index 3102b97..168a013 100644 --- a/spec/support/cybele_test_helpers.rb +++ b/spec/support/cybele_test_helpers.rb @@ -49,6 +49,16 @@ def cybele_help_command end end + def cybele_help_run(command: 'ls') + Dir.chdir("#{tmp_path}/#{app_name}") do + Bundler.with_clean_env do + ` + #{command} + ` + end + end + end + def setup_app_dependencies return unless File.exist?(project_path) Dir.chdir(project_path) do