rails_spec = (Gem.loaded_specs["railties"] || Gem.loaded_specs["rails"]) version = rails_spec.version.to_s mongoid = options[:skip_active_record] yarn = !options[:skip_yarn] is_dev = !options[:template].start_with?("http") spring = !options[:skip_spring] if is_dev rocket_cms_path = File.realpath(options[:template] + "/..") end if Gem::Version.new(version) < Gem::Version.new('6.0.0') puts "You are using an old version of Rails (#{version})" puts "Please update" puts "Stopping" exit 1 end git :init remove_file 'Gemfile' create_file 'Gemfile' do <<-TEXT source 'https://rubygems.org' #{' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end '} gem 'rails', '6.0.1' gem 'rails-i18n' #{if mongoid then "gem 'mongoid', '~> 6.1.0'" else "gem 'pg', '>= 0.18', '< 2.0'" end} gem 'turbolinks' #required for redirects even if using via webpack #{ "#{if mongoid then "gem 'rocket_cms_mongoid', path: '#{rocket_cms_path}'" else "gem 'rocket_cms_activerecord', path: '#{rocket_cms_path}'" end} gem 'rocket_cms', path: '#{rocket_cms_path}'" if is_dev} #{"#{if mongoid then "gem 'rocket_cms_mongoid'" else "gem 'rocket_cms_activerecord'" end}" if !is_dev} gem 'glebtv-ckeditor' # wait for https://github.com/sferik/rails_admin/pull/3207 gem 'rails_admin', github: "sferik/rails_admin" gem 'slim' #gem 'sass' #gem 'sass-rails' gem 'rs-webpack-rails' gem 'devise' gem 'devise-i18n' gem 'cancancan' #{if mongoid then "gem 'cancancan'" end} gem 'cloner' gem 'puma' gem 'sentry-raven' gem 'shrine' #{"gem 'shrine-mongoid'" if mongoid} gem 'image_processing' #gem 'uglifier' #gem 'rs_russian' #gem 'enumerize' #gem 'active_model_serializers' # windows gem 'tzinfo-data' if Gem.win_platform? gem 'wdm', '>= 0.1.0' if Gem.win_platform? gem 'bootsnap', require: false gem 'irb' group :development do #gem 'binding_of_caller' #gem 'better_errors', github: 'charliesome/better_errors' #gem 'pry-rails' gem 'listen' gem 'annotate' #{" gem 'spring'" if spring} gem 'capistrano', require: false gem 'capistrano-bundler', require: false gem 'capistrano3-puma', require: false gem 'capistrano-rails', require: false end group :development, :test do gem "factory_bot_rails" gem 'rspec-rails' #{if mongoid then " gem 'mongoid-rspec'" else "" end} gem 'capybara' # https://github.com/mattheworiordan/capybara-screenshot/issues/243 gem 'capybara-screenshot' gem 'selenium-webdriver' gem 'webdrivers' gem 'database_cleaner' #{if mongoid then " gem 'database_cleaner-mongoid'" else "" end} #gem 'database_cleaner-redis' gem 'ffaker' gem 'timecop' gem "pry-rails" gem 'childprocess' end TEXT end remove_file '.gitignore' create_file '.gitignore' do <<-TEXT # See https://help.github.com/articles/ignoring-files for more about ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' /.bundle /log/*.log *.swp /tmp /public/system /public/ckeditor_assets /public/assets /node_modules /public/webpack #{if mongoid then '/config/mongoid.yml' else '/config/database.yml' end} /config/secrets.yml yarn-error.log spec/examples.txt TEXT end create_file 'extra/.gitkeep', '' remove_file 'app/controllers/application_controller.rb' create_file 'app/controllers/application_controller.rb' do <<-TEXT class ApplicationController < ActionController::Base include RocketCMS::Controller def page_title #default page title "#{app_name}" end end TEXT end create_file 'config/navigation.rb' do <<-TEXT # empty file to please simple_navigation, we are not using it # See https://github.com/rs-pro/rocket_cms/blob/master/app/controllers/concerns/rs_menu.rb TEXT end port = rand(100..999) * 10 remove_file 'README.md' create_file 'README.md', "## #{app_name} Project generated by RocketCMS ORM: #{if mongoid then 'Mongoid' else 'ActiveRecord' end} To run (windows): ``` yarn start bundle exec rails s webrick ``` To run (nix/mac): ``` yarn start puma ``` " #create_file '.ruby-version', "2.6.5\n" #create_file '.ruby-gemset', "#{app_name}\n" run 'bundle install --without production' if mongoid create_file 'config/mongoid.yml' do <<-TEXT development: clients: default: database: #{app_name.downcase}_development hosts: - localhost:27017 test: clients: default: database: #{app_name.downcase}_test hosts: - localhost:27017 TEXT end else remove_file 'config/database.yml' create_file 'config/database.yml' do <<-TEXT development: adapter: postgresql encoding: unicode database: #{app_name.downcase}_development pool: 5 host: 'localhost' username: #{app_name.downcase} password: #{app_name.downcase} template: template0 test: adapter: postgresql encoding: unicode database: #{app_name.downcase}_test pool: 5 host: 'localhost' username: #{app_name.downcase} password: #{app_name.downcase} template: template0 TEXT end say "Please create a PostgreSQL user #{app_name.downcase} with password #{app_name.downcase} and a database #{app_name.downcase}_development owned by him for development NOW.", :red ask("Press when done.") end unless mongoid generate 'simple_captcha' end generate "simple_form:install" generate "devise:install" generate "devise", "User" remove_file "config/locales/devise.en.yml" remove_file "config/locales/en.yml" gsub_file 'app/models/user.rb', '# :confirmable, :lockable, :timeoutable and :omniauthable', '# :confirmable, :registerable, :timeoutable and :omniauthable' gsub_file 'app/models/user.rb', ':registerable,', ' :lockable,' gsub_file Dir.glob("db/migrate/*_devise_create_users.rb").first, '# t.datetime :locked_at', 't.datetime :locked_at' if mongoid gsub_file 'app/models/user.rb', '# field :failed_attempts', 'field :failed_attempts' gsub_file 'app/models/user.rb', '# field :unlock_token', 'field :unlock_token' gsub_file 'app/models/user.rb', '# field :locked_at', 'field :locked_at' end if mongoid generate "ckeditor:install", "--orm=mongoid", "--backend=shrine" else generate "ckeditor:install", "--orm-active_record", "--backend=shrine" end remove_file 'config/initializers/ckeditor_shrine.rb' unless mongoid generate "rocket_cms:migration" generate "rails_admin_settings:migration" end generate "rocket_cms:admin" generate "rocket_cms:ability" generate "rocket_cms:layout" generate "rocket_cms:webpack", port+1 unless mongoid rake "db:migrate" end generate "rspec:install" remove_file 'config/routes.rb' create_file 'config/routes.rb' do <<-TEXT Rails.application.routes.draw do devise_for :users mount RailsAdmin::Engine => '/admin', as: 'rails_admin' mount Ckeditor::Engine => '/ckeditor' #get 'contacts' => 'contacts#new', as: :contacts #post 'contacts' => 'contacts#create', as: :create_contacts #get 'contacts/sent' => 'contacts#sent', as: :contacts_sent #get 'search' => 'search#index', as: :search #resources :news, only: [:index, :show] root to: 'home#index' get '*slug' => 'pages#show' resources :pages, only: [:show] end TEXT end create_file 'config/locales/ru.yml' do <<-TEXT ru: TEXT end remove_file 'db/seeds.rb' require 'securerandom' admin_pw = SecureRandom.urlsafe_base64(6) create_file 'db/seeds.rb' do <<-TEXT admin_pw = "#{admin_pw}" User.destroy_all User.create!(email: 'admin@#{app_name.dasherize.downcase}.ru', password: admin_pw, password_confirmation: admin_pw) Page.destroy_all Menu.destroy_all News.destroy_all h = Menu.create(name: 'Главное', text_slug: 'main').id Page.create!(name: 'О компании', fullpath: '/company', menu_ids: [h], content: 'О Компании') Page.create!(name: 'Новости', fullpath: '/news', menu_ids: [h]) Page.create!(name: 'Контакты', fullpath: '/contacts', menu_ids: [h], content: 'Текст стр контакты') 3.times do |i| News.create!(name: "test " + i.to_s, content: "test", time: i.days.ago) end TEXT end create_file 'app/uploaders/news_uploader.rb' do <<-TEXT class NewsUploader < Shrine plugin :determine_mime_type plugin :validation_helpers plugin :derivatives Attacher.validate do validate_mime_type_inclusion %w[image/jpeg image/gif image/png] validate_max_size 2.megabytes end Attacher.derivatives do |original| magick = ImageProcessing::MiniMagick.source(original) { main: magick.resize_to_limit!(800, 800), thumb: magick.resize_to_limit!(300, 300) } end end TEXT end create_file 'app/uploaders/og_image_uploader.rb' do <<-TEXT class OgImageUploader < Shrine plugin :determine_mime_type plugin :validation_helpers Attacher.validate do validate_mime_type_inclusion %w[image/jpeg image/gif image/png] validate_max_size 2.megabytes end end TEXT end create_file 'extra/shrine/plugins/custom_pretty_location.rb' do <<-TEXT require 'shrine/plugins/pretty_location' class Shrine module Plugins module CustomPrettyLocation def self.configure(uploader, **opts) uploader.opts[:custom_pretty_location] ||= { identifier: :id } uploader.opts[:custom_pretty_location].merge!(opts) end module InstanceMethods def generate_location(io, **options) custom_pretty_location(io, **options) end def custom_pretty_location(io, name: nil, record: nil, version: nil, derivative: nil, identifier: nil, metadata: {}, **) if record namespace = record_namespace(record) identifier ||= record_identifier(record) end basename = basic_location(io, metadata: metadata) basename = [*(version || derivative), basename].join("-") [*namespace, *identifier, *name, basename].join("/") end private def record_identifier(record) id = record.public_send(opts[:custom_pretty_location][:identifier]) case id when Integer str_id = "%09d".freeze % id str_id.scan(/\\d{3}/).join("/".freeze) when String id.scan(/.{3}/).first(3).join("/".freeze) else # NOTE: 'raise' cannot be used. It fails on save. nil end end def transform_class_name(class_name) if opts[:custom_pretty_location][:class_underscore] class_name.gsub(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2').gsub(/([a-z])([A-Z])/, '\\1_\\2').downcase else class_name.downcase end end def record_namespace(record) class_name = record.class.name or return parts = transform_class_name(class_name).split("::") if separator = opts[:custom_pretty_location][:namespace] parts.join(separator) else parts.last end end end end register_plugin(:custom_pretty_location, CustomPrettyLocation) end end TEXT end remove_file 'app/assets/config/manifest.js' create_file 'app/assets/config/manifest.js' do <<-TEXT //= link_tree ../images //= link_directory ../stylesheets .css //= link ckcontent.css //= link ckeditor/application.css //= link ckeditor/application.js TEXT end remove_file 'config/initializers/assets.rb' create_file 'config/initializers/assets.rb' do <<-TEXT # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path # Add Yarn node_modules folder to the asset load path. #Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) TEXT end create_file 'config/initializers/shrine.rb' do <<-TEXT require "shrine" require "shrine/storage/file_system" Shrine.logger = Rails.logger # Choose your favorite image processor require 'image_processing/mini_magick' SHRINE_PICTURE_PROCESSOR = ImageProcessing::MiniMagick Shrine.storages = { # temporary cache: Shrine::Storage::FileSystem.new( "public", prefix: "uploads/cache" ), # permanent store: Shrine::Storage::FileSystem.new( "public", prefix: "uploads" ), } Shrine.plugin :upload_options, cache: { move: true }, store: { move: true } Shrine.plugin :custom_pretty_location, class_underscore: :true Shrine.plugin :determine_mime_type #{"Shrine.plugin :mongoid" if mongoid} Shrine.plugin :instrumentation Shrine.plugin :activerecord # loads Active Record integration Shrine.plugin :cached_attachment_data # enables retaining cached file across form redisplays Shrine.plugin :restore_cached_data # extracts metadata for assigned cached files Shrine.plugin :validation_helpers Shrine.plugin :derivatives require 'ckeditor/backend/shrine' TEXT end create_file 'config/initializers/rack.rb' do <<-TEXT Rack::Utils.multipart_part_limit = 0 TEXT end create_file 'app/assets/stylesheets/rails_admin/custom/theming.sass' do <<-TEXT TEXT end remove_file 'public/robots.txt' create_file 'public/robots.txt' do <<-TEXT User-Agent: * Disallow: / TEXT end remove_file 'app/helpers/application_helper.rb' create_file 'app/helpers/application_helper.rb' do <<-TEXT module ApplicationHelper def body_class r = [] #{'r.push "b-#{params[:controller].gsub("/", "_")}"'} #{'r.push "b-#{params[:controller].gsub("/", "_")}-#{params[:action]}"'} r.join(" ") end end TEXT end remove_file 'config/puma.rb' create_file 'config/puma.rb' do <<-TEXT # Min and Max threads per worker threads 1, 3 current_dir = File.expand_path("../..", __FILE__) base_dir = File.expand_path("../../..", __FILE__) # rackup DefaultRackup # Default to production rails_env = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || "development" environment rails_env if rails_env == 'development' Puma.windows? { workers 1 } bind 'tcp://0.0.0.0:#{port}' else # https://github.com/seuros/capistrano-puma/blob/642d141ee502546bd5a43a76cd9f6766dc0fcc7a/lib/capistrano/templates/puma.rb.erb#L25 prune_bundler preload_app! # Change to match your CPU core count workers 1 #{'shared_dir = "#{base_dir}/shared"'} # Set up socket location #bind 'tcp://0.0.0.0:4000' #{'socket_dir = "#{shared_dir}/tmp/puma/"'} #{'Dir.mkdir socket_dir unless File.directory? socket_dir'} #{'bind "unix://#{shared_dir}/tmp/puma/socket"'} # Logging #{'stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true'} # Set master PID and state locations #{'pidfile "#{shared_dir}/tmp/puma/pid"'} #{'state_path "#{shared_dir}/tmp/puma/state"'} activate_control_app on_restart do puts 'Refreshing Gemfile' #{'ENV["BUNDLE_GEMFILE"] = "#{current_dir}/Gemfile" unless rails_env == \'development\''} end #{"#mongoid reconnects by itself" if mongoid} #{'on_worker_boot do require "active_record" ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished ActiveRecord::Base.establish_connection(YAML.load_file("#{base_dir}/current/config/database.yml")[rails_env]) end' if !mongoid} end TEXT end remove_file 'app/views/layouts/application.html.erb' remove_file 'config/application.rb' create_file 'config/application.rb' do <<-TEXT require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: require "active_model/railtie" #{'#' if mongoid}require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "action_cable/engine" require "active_storage/engine" require "sprockets/railtie" # require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module #{app_name.camelize} class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.0 config.generators do |g| g.test_framework :rspec g.view_specs false g.helper_specs false g.feature_specs false g.template_engine :slim g.stylesheets false g.javascripts false g.helper false g.fixture_replacement :factory_bot, :dir => 'spec/factories' end config.i18n.locale = :ru config.i18n.default_locale = :ru config.i18n.available_locales = [:ru, :en] config.i18n.enforce_available_locales = true # #{'config.active_record.schema_format = :sql' unless mongoid} #{'config.autoload_paths += %W(#{config.root}/extra)'} #{'config.eager_load_paths += %W(#{config.root}/extra)'} config.time_zone = 'Europe/Moscow' config.webpack.dev_server.manifest_port = #{port+1} #config.webpack.dev_server.manifest_host = "192.168.1.1" config.webpack.dev_server.host = proc { request.host } config.webpack.dev_server.port = #{port+1} config.webpack.manifest_type = "manifest" config.webpack.dev_server.enabled = Rails.env.development? end end TEXT end remove_file 'app/assets/javascripts/application.js' create_file 'app/assets/javascripts/application.js' do <<-TEXT TEXT end remove_file 'app/assets/stylesheets/application.css' create_file 'app/assets/stylesheets/application.css' do <<-TEXT TEXT end create_file 'app/assets/stylesheets/ckcontent.css' do <<-TEXT div.red { color: red; } TEXT end if mongoid FileUtils.cp(Pathname.new(destination_root).join('config', 'mongoid.yml').to_s, Pathname.new(destination_root).join('config', 'mongoid.yml.example').to_s) else FileUtils.cp(Pathname.new(destination_root).join('config', 'database.yml').to_s, Pathname.new(destination_root).join('config', 'database.yml.example').to_s) end remove_file 'config/secrets.yml' key = SecureRandom.hex(64) create_file 'config/secrets.yml' do <<-TEXT development: secret_key_base: #{key} production: secret_key_base: #{key} test: secret_key_base: #{key} TEXT end remove_file 'config/credentials.yml.enc' remove_file 'config/master.key' create_file 'Procfile' do <<-TEXT web: bundle exec puma webpack: yarn start TEXT end unless mongoid create_file 'Dockerfile' do <<-TEXT # docker build -t #{app_name.downcase} /root/#{app_name.downcase}/ FROM ruby:2.5.1-stretch RUN apt-get update -qq >/dev/null RUN apt-get install -y -qq postgresql postgresql-contrib libpq-dev cmake libpq5 >/dev/null RUN apt-get install -y -qq locales apt-utils apt-transport-https >/dev/null RUN apt-get install -y -qq qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x >/dev/null RUN apt-get install -y -qq xvfb > /dev/null RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN apt-get update -qq >/dev/null RUN apt-get install -y -qq yarn >/dev/null RUN echo "en_US UTF-8" > /etc/locale.gen RUN locale-gen en_US.UTF-8 ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US:en ENV LC_ALL=en_US.UTF-8 RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash RUN /bin/bash -c "source /root/.bashrc && nvm install node && nvm use node" ENV TZ=Europe/Moscow RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone TEXT end create_file '.gitlab-ci.yml' do <<-TEXT image: #{app_name.downcase}:latest services: - postgres:latest variables: POSTGRES_DB: #{app_name.downcase}_test POSTGRES_USER: #{app_name.downcase} POSTGRES_PASSWORD: "#{app_name.downcase}" cache: untracked: true key: "$CI_PROJECT_ID" paths: - node_modules/ - .bundled/ - .yarn - tmp/cache rspec: before_script: - source /root/.bashrc - nvm use node - cp -f config/database.yml.ci config/database.yml - cp -f config/secrets.yml.sample config/secrets.yml - cat config/database.yml - cat config/secrets.yml - ruby -v - which ruby - export RAILS_ENV=test - export CI=YES - gem install bundler --no-ri --no-rdoc - bundle install --jobs $(nproc) --path=/cache/bundler - yarn --version - yarn config set cache-folder .yarn - yarn install - bundle exec rake webpack:compile - date - RAILS_ENV=test bundle exec rake db:create db:schema:load script: - RAILS_ENV=test xvfb-run -a bundle exec rspec - bundle exec pronto run -c=origin/master --exit-code dependency_scanning: image: docker:stable variables: DOCKER_DRIVER: overlay2 allow_failure: true services: - docker:stable-dind script: - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\\([0-9]*\\)\\.\\([0-9]*\\).*/\\1-\\2-stable/') - docker run --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}" --volume "$PWD:/code" --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code artifacts: paths: [gl-dependency-scanning-report.json] TEXT end create_file "config/database.yml.ci" do <<-TEXT test: adapter: postgresql encoding: unicode database: #{app_name.downcase}_test pool: 5 host: postgres username: #{app_name.downcase} password: #{app_name.downcase} template: template0 TEXT end create_file "config/secrets.yml.sample" do <<-TEXT test: secret_key_base: #{key} TEXT end create_file "spec/features/home_page_spec.rb" do <<-TEXT require 'rails_helper' RSpec.feature 'main page', :js do scenario "visit" do visit root_path expect(page.status_code).to eq(200).or eq(304) end end TEXT end create_file "spec/support/capybara.rb" do <<-TEXT if ENV['CI'] Selenium::WebDriver::Chrome.path = '/usr/bin/google-chrome-stable' else begin Selenium::WebDriver::Chrome.path = '/usr/bin/chromium' rescue Selenium::WebDriver::Error::WebDriverError end end Capybara.register_driver :chrome_root do |app| service = ::Selenium::WebDriver::Service.chrome#(args: { verbose: true, log_path: 'chromedriver.log' }) options = ::Selenium::WebDriver::Chrome::Options.new options.args << '--headless' unless ENV['NO_HEADLESS'] options.args << '--no-sandbox' options.args << '--window-size=1280,1024' Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, service: service) end # не работает, установлено выше # Capybara::Screenshot.webkit_options = { width: 1280, height: 1024 } if ENV['CHROME_VISIBLE'] Capybara.javascript_driver = :selenium_chrome else Capybara.javascript_driver = :chrome_root end Capybara.default_driver = :rack_test Capybara.default_max_wait_time = 15 Capybara.register_server :puma do |app, port, host| require 'rack/handler/puma' Rack::Handler::Puma.run(app, Host: host, Port: port, Threads: "1:1") end Capybara.configure do |config| config.app_host = "http://\#{Rails.application.secrets.host}" config.server = :puma config.server_port = 9332 config.run_server = true config.always_include_port = true end Capybara::Screenshot.register_driver(:selenium_chrome) do |driver, path| driver.browser.save_screenshot(path) end Capybara::Screenshot.register_driver(:chrome_root) do |driver, path| driver.browser.save_screenshot(path) end Capybara::Screenshot.autosave_on_failure = true TEXT end create_file "spec/support/database_cleaner.rb" do <<-TEXT RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.clean_with(:truncation) end config.before(:each) do DatabaseCleaner.start end config.after(:each) do DatabaseCleaner.clean end end TEXT end remove_file "spec/rails_helper.rb" create_file "spec/rails_helper.rb" do <<-TEXT # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end # in _spec.rb will both be required and run as specs, causing the specs to be # run twice. It is recommended that you do not name files matching this glob to # end with _spec.rb. You can configure this pattern with the --pattern # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. # # The following line is provided for convenience purposes. It has the downside # of increasing the boot-up time by auto-requiring all files in the support # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } # Checks for pending migrations and applies them before tests are run. # If you are not using ActiveRecord, you can remove this line. ActiveRecord::Migration.maintain_test_schema! require 'capybara/rails' RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures config.fixture_path = "#\{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and # `post` in specs under `spec/controllers`. # # You can disable this behaviour by removing the line below, and instead # explicitly tag your specs with their type, e.g.: # # RSpec.describe UsersController, :type => :controller do # # ... # end # # The different available types are documented in the features, such as in # https://relishapp.com/rspec/rspec-rails/docs config.infer_spec_type_from_file_location! # Filter lines from Rails gems in backtraces. config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") end TEXT end end # end if unless mongoid FileUtils.cp(Pathname.new(destination_root).join('config', 'secrets.yml').to_s, Pathname.new(destination_root).join('config', 'secrets.yml.example').to_s) unless mongoid #generate "paper_trail:install", "--with-associations" generate "paper_trail:install" generate "friendly_id" rake "db:migrate" end if yarn run 'yarn install' else run 'npm install' end git add: "." git commit: %Q{ -m 'Initial commit' } unless mongoid rake "db:migrate" end rake 'db:seed'