diff --git a/.rubocop.yml b/.rubocop.yml index 5b39c3c..9e37cc4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,4 +45,5 @@ Style/IndentHeredoc: Naming/HeredocDelimiterNaming: Exclude: - - 'spec/features/cli_help_spec.rb' \ No newline at end of file + - 'spec/features/cli_help_spec.rb' + - 'spec/features/git_and_git_flow_spec.rb' \ No newline at end of file diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index 96d0816..df8769a 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -101,6 +101,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 4700a34..c5c8ead 100644 --- a/lib/cybele/generators/app_generator.rb +++ b/lib/cybele/generators/app_generator.rb @@ -231,6 +231,11 @@ def configure_error_pages build :configure_error_pages end + def setup_git_and_git_flow + say 'Initialize git and git flow' + build :git_and_git_flow_commands + end + def docker_development_env return if @options[:skip_docker] say 'Setup docker development environment', :green 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..88307f2 --- /dev/null +++ b/spec/features/git_and_git_flow_spec.rb @@ -0,0 +1,32 @@ +# 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