DEV: Apply syntax_tree formatting to spec/*

This commit is contained in:
David Taylor
2023-01-09 11:18:21 +00:00
parent 0cf6421716
commit cb932d6ee1
907 changed files with 58693 additions and 45909 deletions

View File

@ -1,11 +1,11 @@
# frozen_string_literal: true
def list_files(base_dir, pattern = '*')
def list_files(base_dir, pattern = "*")
Dir[File.join("#{base_dir}", pattern)]
end
def list_js_files(base_dir)
list_files(base_dir, '**/*.es6')
list_files(base_dir, "**/*.es6")
end
def grep_files(files, regex)
@ -17,10 +17,10 @@ def grep_file(file, regex)
lines.count > 0 ? file : nil
end
RSpec.describe 'Coding style' do
describe 'Javascript' do
RSpec.describe "Coding style" do
describe "Javascript" do
it 'prevents this.get("foo") pattern' do
js_files = list_js_files('app/assets/javascripts')
js_files = list_js_files("app/assets/javascripts")
offenses = grep_files(js_files, /this\.get\("\w+"\)/)
expect(offenses).to be_empty, <<~TEXT
@ -33,7 +33,7 @@ RSpec.describe 'Coding style' do
end
end
describe 'Post Migrations' do
describe "Post Migrations" do
def check_offenses(files, method_name, constant_name)
method_name_regex = /#{Regexp.escape(method_name)}/
constant_name_regex = /#{Regexp.escape(constant_name)}/
@ -57,8 +57,8 @@ RSpec.describe 'Coding style' do
contains_method_name ? contains_constant_name : true
end
it 'ensures dropped tables and columns are stored in constants' do
migration_files = list_files('db/post_migrate', '**/*.rb')
it "ensures dropped tables and columns are stored in constants" do
migration_files = list_files("db/post_migrate", "**/*.rb")
check_offenses(migration_files, "ColumnDropper.execute_drop", "DROPPED_COLUMNS")
check_offenses(migration_files, "TableDropper.execute_drop", "DROPPED_TABLES")