diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml new file mode 100644 index 0000000..f203d4f --- /dev/null +++ b/.github/workflows/rubyonrails.yml @@ -0,0 +1,51 @@ +# This workflow uses actions that are not certified by GitHub. They are +# provided by a third-party and are governed by separate terms of service, +# privacy policy, and support documentation. +# +# This workflow will install a prebuilt Ruby version, install dependencies, and +# run tests and linters. +name: "Ruby on Rails CI" +on: + push: + branches: [ master, ruby3 ] + pull_request: + branches: [ master, ruby3 ] +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:11-alpine + ports: + - "5432:5432" + env: + POSTGRES_DB: rails_test + POSTGRES_USER: rails + POSTGRES_PASSWORD: password + env: + RAILS_ENV: test + DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + # Runners + - name: Set up database schema + run: RAILS_ENV=test bundle exec rake db:prepare + - name: Run tests + run: bundle exec rspec spec + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + # Runners + - name: Run Rubocop + run: bundle exec rubocop --parallel --format github --format progress diff --git a/.rubocop.yml b/.rubocop.yml index 7b985fe..0bdf1a5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,26 +1,19 @@ AllCops: + NewCops: enable Exclude: - '*.md' - 'Gemfile' - 'Gemfile.lock' - - db/schema.rb - - config/**/*.rb - - script/rails - -Layout/IndentationWidth: - Enabled: false + - 'db/schema.rb' + - 'config/**/*.rb' + - 'script/rails' + - 'vendor/**/*' Metrics/LineLength: Max: 130 Exclude: - '*.gemspec' -Style/RescueModifier: - Enabled: false - -Layout/TrailingBlankLines: - Enabled: false - Lint/UnusedBlockArgument: Exclude: - 'spec/tmp/**/*.rb' @@ -29,31 +22,14 @@ Style/BlockComments: Exclude: - 'spec/spec_helper.rb' -Style/FrozenStringLiteralComment: - Enabled: false - Metrics/BlockLength: - Exclude: + Exclude: - 'spec/**/*.rb' -Layout/AlignParameters: - EnforcedStyle: 'with_fixed_indentation' - -Layout/MultilineMethodCallIndentation: - EnforcedStyle: 'indented' - Style/Documentation: Exclude: - 'db/migrate/*.rb' - 'spec/**/*.rb' -# These may break ruby 1.9 support: - -Layout/IndentHeredoc: - Enabled: false - -Style/HashSyntax: - Enabled: false - -Style/ExpandPathArguments: - Enabled: false \ No newline at end of file +Gemspec/DevelopmentDependencies: + EnforcedStyle: "gemspec" \ No newline at end of file diff --git a/.ruby-version b/.ruby-version index 914ec96..b0f2dcb 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.0 \ No newline at end of file +3.0.4 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4f889a6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: ruby - - -matrix: - include: - - rvm: 1.9.3 - gemfile: gemfiles/Gemfile.rails-3.2.x - - rvm: 1.9.3 - gemfile: Gemfile - - rvm: 2.0.0 - gemfile: Gemfile - - rvm: 2.1.4 - gemfile: Gemfile - - rvm: 2.2.3 - gemfile: Gemfile - - rvm: 2.6.0 - gemfile: Gemfile - -script: bundle exec rake db:migrate RAILS_ENV=test && bundle exec rspec spec \ No newline at end of file diff --git a/Rakefile b/Rakefile index 54bb562..4afb503 100755 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,9 @@ #!/usr/bin/env rake +# frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) AfterParty::Application.load_tasks diff --git a/after_party.gemspec b/after_party.gemspec index 2bcede8..3911f43 100644 --- a/after_party.gemspec +++ b/after_party.gemspec @@ -1,7 +1,10 @@ +# frozen_string_literal: true + +require_relative 'lib/version' + Gem::Specification.new do |gem| gem.name = 'after_party' - gem.version = '1.11.2' - gem.date = '2019-03-25' + gem.version = Version::VERSION gem.authors = 'Steve Mitchell' gem.description = 'Automated post-deploy tasks for Ruby/Rails. Your deployment is the party. This is the after party' @@ -13,12 +16,15 @@ Gem::Specification.new do |gem| gem.files = Dir['lib/**/**'] gem.require_path = 'lib' - gem.add_development_dependency 'activerecord' - gem.add_development_dependency 'factory_bot' - gem.add_development_dependency 'generator_spec' - gem.add_development_dependency 'mongoid' - gem.add_development_dependency 'rspec' - gem.add_development_dependency 'rspec-rails', '~> 3.4' - gem.add_development_dependency 'rubocop' - gem.add_development_dependency 'sqlite3', '~> 1.3.6' -end \ No newline at end of file + gem.required_ruby_version = '~> 3.0' + + gem.add_development_dependency 'activerecord', '~> 7' + gem.add_development_dependency 'factory_bot', '~> 6' + gem.add_development_dependency 'generator_spec', '~> 0' + gem.add_development_dependency 'mongoid', '~> 7' + gem.add_development_dependency 'pg', '~> 1' + gem.add_development_dependency 'rspec', '~> 3' + gem.add_development_dependency 'rspec-rails', '~> 5' + gem.add_development_dependency 'rubocop', '~> 1' + gem.metadata['rubygems_mfa_required'] = 'true' +end diff --git a/config.ru b/config.ru index c4910e9..252e660 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,6 @@ +# frozen_string_literal: true + # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require File.expand_path('config/environment', __dir__) run AfterParty::Application diff --git a/config/application.rb b/config/application.rb index ed00f18..f1a9dcc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -44,13 +44,12 @@ class Application < Rails::Application ActiveRecord::SchemaDumper.ignore_tables = /^ar_internal*/ - if ActiveRecord::VERSION::MAJOR >= 5 - config.active_record.sqlite3.represent_boolean_as_integer = true - end - # Use SQL instead of Active Record's schema dumper when creating the database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql + + + config.active_record.legacy_connection_handling = false end end diff --git a/config/database.yml b/config/database.yml index 51a4dd4..bd21d93 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,25 +1,11 @@ -# SQLite version 3.x -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' development: - adapter: sqlite3 - database: db/development.sqlite3 + adapter: postgresql + database: after_party_dev pool: 5 timeout: 5000 -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: sqlite3 - database: db/production.sqlite3 + adapter: postgresql + database: after_party_test pool: 5 timeout: 5000 diff --git a/config/initializers/after_party.rb b/config/initializers/after_party.rb new file mode 100644 index 0000000..d9848b4 --- /dev/null +++ b/config/initializers/after_party.rb @@ -0,0 +1,7 @@ +AfterParty.setup do |config| + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'after_party/active_record.rb' +end \ No newline at end of file diff --git a/db/migrate/20130208204820_create_task_records.rb b/db/migrate/20130208204820_create_task_records.rb index e529e7e..1f290a6 100644 --- a/db/migrate/20130208204820_create_task_records.rb +++ b/db/migrate/20130208204820_create_task_records.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + if ActiveRecord::VERSION::MAJOR >= 5 class CreateTaskRecords < ActiveRecord::Migration[4.2] def change - create_table :task_records, :id => false do |t| - t.string :version, :null => false + create_table :task_records, id: false do |t| + t.string :version, null: false end end end @@ -10,8 +12,8 @@ def change else class CreateTaskRecords < ActiveRecord::Migration def change - create_table :task_records, :id => false do |t| - t.string :version, :null => false + create_table :task_records, id: false do |t| + t.string :version, null: false end end end diff --git a/db/schema.rb b/db/schema.rb index 57be945..bf233a6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,16 +2,15 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2013_02_08_204820) do - +ActiveRecord::Schema[7.0].define(version: 2013_02_08_204820) do create_table "task_records", id: false, force: :cascade do |t| t.string "version", null: false end diff --git a/lib/after_party.rb b/lib/after_party.rb index 1a41235..0fa10b9 100644 --- a/lib/after_party.rb +++ b/lib/after_party.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # AfterParty is a moduke defined by gem after_party module AfterParty - require 'after_party/railtie.rb' if defined?(Rails) + require 'after_party/railtie' if defined?(Rails) def self.setup yield self end -end \ No newline at end of file +end diff --git a/lib/after_party/active_record.rb b/lib/after_party/active_record.rb index 0177d05..4bdbb31 100644 --- a/lib/after_party/active_record.rb +++ b/lib/after_party/active_record.rb @@ -1 +1,3 @@ -require 'after_party/models/active_record/task_record.rb' \ No newline at end of file +# frozen_string_literal: true + +require 'after_party/models/active_record/task_record' diff --git a/lib/after_party/models/active_record/task_record.rb b/lib/after_party/models/active_record/task_record.rb index fa07ac4..5611326 100644 --- a/lib/after_party/models/active_record/task_record.rb +++ b/lib/after_party/models/active_record/task_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AfterParty # Task Record is a persisted object recorded when a taks is run. class TaskRecord < ActiveRecord::Base @@ -7,4 +9,4 @@ def self.completed_task?(version) all.any? { |t| t.version == version } end end -end \ No newline at end of file +end diff --git a/lib/after_party/models/mongoid/task_record.rb b/lib/after_party/models/mongoid/task_record.rb index 7850623..519ea46 100644 --- a/lib/after_party/models/mongoid/task_record.rb +++ b/lib/after_party/models/mongoid/task_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AfterParty # Task Record is a persisted object recorded when a taks is run. class TaskRecord @@ -10,4 +12,4 @@ def self.completed_task?(version) all.any? { |t| t.version == version } end end -end \ No newline at end of file +end diff --git a/lib/after_party/models/task_recorder.rb b/lib/after_party/models/task_recorder.rb index 6ccec28..2129381 100644 --- a/lib/after_party/models/task_recorder.rb +++ b/lib/after_party/models/task_recorder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AfterParty # Task Recorder is responsible for collecting pending tasks and recording their execution class TaskRecorder @@ -8,8 +10,8 @@ class TaskRecorder def self.pending_files Dir[FILE_MASK].collect { |f| TaskRecorder.new(f) } - .select(&:pending?) - .sort_by(&:timestamp) + .select(&:pending?) + .sort_by(&:timestamp) end def initialize(filename = '') @@ -28,4 +30,4 @@ def parse_filename end end end -end \ No newline at end of file +end diff --git a/lib/after_party/mongoid.rb b/lib/after_party/mongoid.rb index f9b74fd..3ef15ae 100644 --- a/lib/after_party/mongoid.rb +++ b/lib/after_party/mongoid.rb @@ -1 +1,3 @@ -require 'after_party/models/mongoid/task_record.rb' \ No newline at end of file +# frozen_string_literal: true + +require 'after_party/models/mongoid/task_record' diff --git a/lib/after_party/railtie.rb b/lib/after_party/railtie.rb index 0ec322b..eb2702a 100644 --- a/lib/after_party/railtie.rb +++ b/lib/after_party/railtie.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'after_party' require 'rails' module AfterParty @@ -16,4 +18,4 @@ class Railtie < Rails::Railtie load 'generators/install/install_generator.rb' end end -end \ No newline at end of file +end diff --git a/lib/generators/install/install_generator.rb b/lib/generators/install/install_generator.rb index d039cc7..044d1a3 100644 --- a/lib/generators/install/install_generator.rb +++ b/lib/generators/install/install_generator.rb @@ -1,11 +1,13 @@ +# frozen_string_literal: true + require 'rails/generators' module AfterParty module Generators # Generates the after_party.rb in config/initializers and a migration file class InstallGenerator < Rails::Generators::Base - source_root File.expand_path('../templates', __FILE__) - argument :orm_name, :type => :string, :default => 'active_record' + source_root File.expand_path('templates', __dir__) + argument :orm_name, type: :string, default: 'active_record' def create_initializer_file template 'after_party.txt.erb', 'config/initializers/after_party.rb' @@ -50,4 +52,4 @@ def table_name end end end -end \ No newline at end of file +end diff --git a/lib/generators/task/task_generator.rb b/lib/generators/task/task_generator.rb index 37455aa..adfc69d 100644 --- a/lib/generators/task/task_generator.rb +++ b/lib/generators/task/task_generator.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + require 'date' module AfterParty module Generators # creates after_party tasks class TaskGenerator < Rails::Generators::Base - source_root(File.expand_path('../templates', __FILE__)) + source_root(File.expand_path('templates', __dir__)) argument(:name, type: :string) class_option( :description, @@ -37,4 +39,4 @@ def timestamp end end end -end \ No newline at end of file +end diff --git a/lib/tasks/deploy_task_runner.rake b/lib/tasks/deploy_task_runner.rake index a52fccb..3b84cce 100644 --- a/lib/tasks/deploy_task_runner.rake +++ b/lib/tasks/deploy_task_runner.rake @@ -1,6 +1,8 @@ +# frozen_string_literal: true + namespace :after_party do desc 'runs (in order) all pending after_party deployment tasks, if they have not run yet against the current db.' - task :run => :environment do + task run: :environment do tasks = AfterParty::TaskRecorder.pending_files.map { |f| "after_party:#{f.task_name}" } tasks.each { |t| Rake::Task[t].invoke } @@ -9,8 +11,8 @@ namespace :after_party do end desc 'Check the status of after_party deployment tasks' - task :status => :environment do - tasks = Dir[AfterParty::TaskRecorder::FILE_MASK].sort.collect do |filename| + task status: :environment do + tasks = Dir[AfterParty::TaskRecorder::FILE_MASK].collect do |filename| recorder = AfterParty::TaskRecorder.new(filename) { version: recorder.timestamp, @@ -19,9 +21,9 @@ namespace :after_party do } end - puts <<-TABLE -Status Task ID Task Name --------------------------------------------------- + puts <<~TABLE + Status Task ID Task Name + -------------------------------------------------- TABLE tasks.each do |task| puts " #{task[:status]} #{task[:version]} #{task[:task_name].capitalize}" diff --git a/lib/version.rb b/lib/version.rb new file mode 100644 index 0000000..aeddf64 --- /dev/null +++ b/lib/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Version + VERSION = '3.0.0' +end diff --git a/spec/factories/task_record.rb b/spec/factories/task_record.rb index af274b4..d7c1552 100644 --- a/spec/factories/task_record.rb +++ b/spec/factories/task_record.rb @@ -1,6 +1,9 @@ +# frozen_string_literal: true + # Read about factories at https://github.com/thoughtbot/factory_girl FactoryBot.define do factory :task_record, class: 'AfterParty::TaskRecord' do + # TODO: check if it is needed end end diff --git a/spec/fixtures/tasks/deployment/20120205141454_m_three.rake b/spec/fixtures/tasks/deployment/20120205141454_m_three.rake index 51f8af4..b0c9aca 100644 --- a/spec/fixtures/tasks/deployment/20120205141454_m_three.rake +++ b/spec/fixtures/tasks/deployment/20120205141454_m_three.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :after_party do desc 'Deployment task: a_description_of_said_task' task m_three: :environment do @@ -8,4 +10,4 @@ namespace :after_party do AfterParty::TaskRecord .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp end -end \ No newline at end of file +end diff --git a/spec/fixtures/tasks/deployment/20130205176456_z_first.rake b/spec/fixtures/tasks/deployment/20130205176456_z_first.rake index 4e02b4e..360abd8 100644 --- a/spec/fixtures/tasks/deployment/20130205176456_z_first.rake +++ b/spec/fixtures/tasks/deployment/20130205176456_z_first.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :after_party do desc 'Deployment task: a_description_of_said_task' task z_first: :environment do @@ -8,4 +10,4 @@ namespace :after_party do AfterParty::TaskRecord .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp end -end \ No newline at end of file +end diff --git a/spec/fixtures/tasks/deployment/20130207948264_a_second2.rake b/spec/fixtures/tasks/deployment/20130207948264_a_second2.rake index 5dd7ed7..757cb7e 100644 --- a/spec/fixtures/tasks/deployment/20130207948264_a_second2.rake +++ b/spec/fixtures/tasks/deployment/20130207948264_a_second2.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :after_party do desc 'Deployment task: a_description_of_said_task' task a_second2: :environment do @@ -8,4 +10,4 @@ namespace :after_party do AfterParty::TaskRecord .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp end -end \ No newline at end of file +end diff --git a/spec/generators/install_generator_spec.rb b/spec/generators/install_generator_spec.rb index 09074e3..1a3912e 100644 --- a/spec/generators/install_generator_spec.rb +++ b/spec/generators/install_generator_spec.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'spec_helper' require 'generator_spec/test_case' describe AfterParty::Generators::InstallGenerator do include GeneratorSpec::TestCase - destination File.expand_path('../../tmp', __FILE__) + destination File.expand_path('../tmp', __dir__) context 'with active_record' do arguments %w[active_record] @@ -14,7 +16,7 @@ end it 'creates an initializer' do - assert_file 'config/initializers/after_party.rb', %r{require 'after_party\/active_record.rb'} + assert_file 'config/initializers/after_party.rb', %r{require 'after_party/active_record.rb'} end it 'creates the migration file ' do @@ -70,7 +72,7 @@ describe AfterParty::Generators::InstallGenerator do include GeneratorSpec::TestCase - destination File.expand_path('../../tmp', __FILE__) + destination File.expand_path('../tmp', __dir__) context 'with mongoid' do arguments %w[mongoid] @@ -89,4 +91,4 @@ assert_no_migration 'db/migrate/create_task_records.rb' end end -end \ No newline at end of file +end diff --git a/spec/generators/task_generator_spec.rb b/spec/generators/task_generator_spec.rb index 9c7c68e..d053328 100644 --- a/spec/generators/task_generator_spec.rb +++ b/spec/generators/task_generator_spec.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + require 'spec_helper' describe AfterParty::Generators::TaskGenerator do require 'generator_spec/test_case' include GeneratorSpec::TestCase - destination File.expand_path('../../tmp', __FILE__) + destination File.expand_path('../tmp', __dir__) before(:all) do prepare_destination @@ -14,7 +16,7 @@ it 'creates the migration file and takes description from arguments ' do run_generator %w[a_first_task_that_I_need_to_run --description=a_description_of_said_task] assert_generated 'lib/tasks/deployment/a_first_task_that_i_need_to_run.rake', - /desc 'Deployment task: a_description_of_said_task'/ + /desc 'Deployment task: a_description_of_said_task'/ end end @@ -22,7 +24,7 @@ it 'creates the migration file and uses task name as its description' do run_generator ['a_task_that_I_need_to_run'] assert_generated 'lib/tasks/deployment/a_task_that_i_need_to_run.rake', - /desc 'Deployment task: a_task_that_i_need_to_run'/ + /desc 'Deployment task: a_task_that_i_need_to_run'/ end end @@ -34,10 +36,10 @@ def assert_generated(relative, *contents, &block) assert_file file_name, *contents, &block end - def task_file_name(relative) #:nodoc: + def task_file_name(relative) # :nodoc: absolute = File.expand_path(relative, destination_root) dirname = File.dirname(absolute) file_name = File.basename(absolute).sub(/\.rb$/, '').downcase Dir.glob("#{dirname}/[0-9]*_*.rake").grep(/\d+_#{file_name}$/).first end -end \ No newline at end of file +end diff --git a/spec/models/task_recorder_spec.rb b/spec/models/task_recorder_spec.rb index 69dfd57..214b877 100644 --- a/spec/models/task_recorder_spec.rb +++ b/spec/models/task_recorder_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'fileutils' @@ -6,9 +8,9 @@ module AfterParty include FileUtils before(:all) do - FILE_PATH = File.join(Rails.root, 'spec/fixtures/tasks/deployment/') + file_path = File.join(Rails.root, 'spec/fixtures/tasks/deployment/') silence_warnings do - TaskRecorder::FILE_MASK = File.join(FILE_PATH, '/*.rake') + TaskRecorder::FILE_MASK = File.join(file_path, '/*.rake') end end @@ -26,8 +28,8 @@ module AfterParty context 'When some tasks have been completed' do before(:all) do - create :task_record, :version => '20120205141454' - create :task_record, :version => '20130207948264' + create :task_record, version: '20120205141454' + create :task_record, version: '20130207948264' end after(:all) do diff --git a/spec/rake_tasks/run_spec.rb b/spec/rake_tasks/run_spec.rb index 8dde9f7..5daeacf 100644 --- a/spec/rake_tasks/run_spec.rb +++ b/spec/rake_tasks/run_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'rake' require 'fileutils' @@ -8,9 +10,9 @@ before(:all) do AfterParty::Application.load_tasks - FILE_PATH = File.join(Rails.root, 'spec/fixtures/tasks/deployment/') + file_path = File.join(Rails.root, 'spec/fixtures/tasks/deployment/') silence_warnings do - AfterParty::TaskRecorder::FILE_MASK = File.join(FILE_PATH, '/*.rake') + AfterParty::TaskRecorder::FILE_MASK = File.join(file_path, '/*.rake') end end diff --git a/spec/rake_tasks/status_spec.rb b/spec/rake_tasks/status_spec.rb index 00807db..0ef7465 100644 --- a/spec/rake_tasks/status_spec.rb +++ b/spec/rake_tasks/status_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'rake' require 'fileutils' @@ -8,16 +10,16 @@ before(:all) do AfterParty::Application.load_tasks - FILE_PATH = File.join(Rails.root, 'spec/fixtures/tasks/deployment/') + file_path = File.join(Rails.root, 'spec/fixtures/tasks/deployment/') silence_warnings do - AfterParty::TaskRecorder::FILE_MASK = File.join(FILE_PATH, '/*.rake') + AfterParty::TaskRecorder::FILE_MASK = File.join(file_path, '/*.rake') end end context 'When some tasks have been completed' do before(:all) do - create :task_record, :version => '20120205141454' - create :task_record, :version => '20130207948264' + create :task_record, version: '20120205141454' + create :task_record, version: '20130207948264' end after(:all) do @@ -25,12 +27,12 @@ end it 'should STDOUT a table with all tasks and their status' do - expected_output = <<-TABLE -Status Task ID Task Name --------------------------------------------------- - up 20120205141454 M three - down 20130205176456 Z first - up 20130207948264 A second2 + expected_output = <<~TABLE + Status Task ID Task Name + -------------------------------------------------- + up 20120205141454 M three + down 20130205176456 Z first + up 20130207948264 A second2 TABLE expect { Rake::Task['after_party:status'].invoke }.to output(/#{expected_output}/).to_stdout end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 05db217..0e879de 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path('../config/environment', __dir__) require 'rspec/rails' require 'factory_bot'