Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RailsInteractive::Templates - RSpec #46

Merged
merged 3 commits into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions lib/rails_interactive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def initialize_project
features
code_quality_tool
admin_panel
testing_tools

create
end
Expand All @@ -45,16 +46,18 @@ def create
# Move to project folder and install gems
Dir.chdir "./#{@inputs[:name]}"

@inputs[:features].each do |feature|
system("bin/rails app:template LOCATION=templates/setup_#{feature}.rb")
end
# Features Templates
handle_multi_options(key: :features)

# Code Quality Template
system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:code_quality_tool]}.rb")

# Admin Panel Template
system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:admin_panel]}.rb")

# Testing tools Template
handle_multi_options(key: :testing_tools)

# Prepare project requirements and give instructions
Message.prepare
end
Expand All @@ -74,6 +77,12 @@ def copy_templates_to_project

private

def handle_multi_options(key:)
@inputs[key].each do |value|
system("bin/rails app:template LOCATION=templates/setup_#{value}.rb")
end
end

def name
@inputs[:name] = Prompt.new("Enter the name of the project: ", "ask", required: true).perform
end
Expand Down Expand Up @@ -108,5 +117,12 @@ def admin_panel
@inputs[:admin_panel] =
Prompt.new("Choose project's admin panel: ", "select", admin_panel).perform
end

def testing_tools
testing_tools = %w[rspec]

@inputs[:testing_tools] =
Prompt.new("Choose project's testing tools: ", "multi_select", testing_tools).perform
end
end
end
13 changes: 13 additions & 0 deletions lib/rails_interactive/templates/setup_rspec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

run "spring stop"

gem_group :development, :test do
gem "rspec-rails"
end

Bundler.with_unbundled_env { run "bundle install" }

rails_command "generate rspec:install"

puts "RSpec is installed!"