diff --git a/.circleci/config.yml b/.circleci/config.yml index 17efdc3b..e94ecebc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,35 +6,168 @@ orbs: executors: test_executor: + parameters: + ruby_version: + type: string + postgres_version: + type: string + working_directory: ~/Challenge_platform + docker: - - image: cimg/ruby:3.2.2 + - image: cimg/ruby:<< parameters.ruby_version >> environment: RAILS_ENV: test + - image: cimg/postgres:<< parameters.postgres_version >> + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: challenge_gov_test + +commands: + prepare_database: + description: 'Prepare the test database' + steps: + - run: bundle exec rake db:setup jobs: - rspec: - executor: + checkout_code: + parameters: + ruby_version: + type: string + postgres_version: + type: string + + executor: name: test_executor + ruby_version: << parameters.ruby_version >> + postgres_version: << parameters.postgres_version >> + steps: - checkout - - run: gem install bundler --version 2.4.13 - - restore_cache: - keys: - - bundle-cache-v1-{{ checksum "Gemfile.lock" }} - - bundle-cache-v1- + - run: - name: Install dependencies - command: bundle install --path vendor/bundle + name: Install Code Climate Test Reporter + command: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + - save_cache: - key: bundle-cache-v1-{{ checksum "Gemfile.lock" }} + key: repo-{{ .Environment.CIRCLE_SHA1 }} paths: - - vendor/bundle + - ~/Challenge_platform + + rspec: + parameters: + ruby_version: + type: string + postgres_version: + type: string + + executor: + name: test_executor + ruby_version: << parameters.ruby_version >> + postgres_version: << parameters.postgres_version >> + + parallelism: 1 + + steps: + - restore_cache: + key: repo-{{ .Environment.CIRCLE_SHA1 }} + + - ruby/install-deps: + key: gems-ruby-<< parameters.ruby_version >>-v{{ .Environment.CACHE_VERSION }} + + - prepare_database + - run: name: Run Tests - command: bundle exec rspec + command: | + mkdir /tmp/test-results + ./cc-test-reporter before-build + + # Run Rspec tests + bundle exec rspec --format progress \ + --format RspecJunitFormatter \ + --out /tmp/test-results/rspec.xml \ + --format progress \ + $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) + + ./cc-test-reporter format-coverage \ + --output coverage/codeclimate.rspec.$CIRCLE_NODE_INDEX.<< parameters.ruby_version >>.json + + - persist_to_workspace: + root: ~/Challenge_platform/coverage + paths: + - codeclimate.rspec.*.json + + # collect reports + - store_test_results: + path: /tmp/test-results + + - store_artifacts: + path: /tmp/test-results + destination: test-results + + report_coverage: + parameters: + ruby_version: + type: string + postgres_version: + type: string + + executor: + name: test_executor + ruby_version: << parameters.ruby_version >> + postgres_version: << parameters.postgres_version >> + + steps: + - restore_cache: + key: repo-{{ .Environment.CIRCLE_SHA1 }} + + - attach_workspace: + at: ~/Challenge_platform/coverage + + - run: + name: Report coverage to Code Climate + command: | + ./cc-test-reporter sum-coverage \ + coverage/codeclimate.*.json \ + --output coverage/codeclimate_full_report.json + + ./cc-test-reporter upload-coverage --input coverage/codeclimate_full_report.json workflows: + version: 2 build_and_test: jobs: - - rspec + - checkout_code: + name: "checkout code: Ruby << matrix.ruby_version >>" + matrix: + parameters: + ruby_version: + - 3.2.2 + postgres_version: + - "16.3" + + - rspec: + requires: + - checkout_code + name: "rspec: Ruby << matrix.ruby_version >>" + matrix: + parameters: + ruby_version: + - 3.2.2 + postgres_version: + - "16.3" + + - report_coverage: + requires: + - "rspec: Ruby << matrix.ruby_version >>" + name: "report coverage: Ruby << matrix.ruby_version >>" + matrix: + parameters: + ruby_version: + - 3.2.2 + postgres_version: + - "16.3" \ No newline at end of file diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 00000000..0f3d3cfc --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,16 @@ +version: '2' +plugins: + brakeman: + enabled: true + rubocop: + enabled: true + channel: rubocop-1-48-1 +exclude_patterns: +- .nix-bundler +- config/ +- db/ +- vendor/ +- "**/vendor/**/*" +- app/assets/images/ +- app/assets/stylesheets/uswds.css +- app/assets/stylesheets/uswds_override.css \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..970aa1c8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: bundler + directory: "/" + target-branch: "production" + schedule: + interval: weekly + ignore: + - dependency-name: "rails" + versions: ["~> 6.0.0"] diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml new file mode 100644 index 00000000..45900d7a --- /dev/null +++ b/.github/workflows/snyk.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: + - dev + - staging + - production + pull_request: + branches: + - dev + - staging + - production + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20.14.0' + + - name: Install Snyk + run: npm install -g snyk + + - name: Authenticate Snyk + run: snyk auth ${{ secrets.SNYK_TOKEN }} + + - name: Run Snyk to check for vulnerabilities + run: snyk test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 74197ddc..a35c7cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ # Ignore master key for decrypting credentials and more. /config/master.key + +/coverage/ \ No newline at end of file diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..c99d2e73 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..9faa4d4f --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,168 @@ +require: + - rubocop-performance + - rubocop-rails + - rubocop-rake + - rubocop-rspec + +AllCops: + NewCops: enable + Exclude: + - 'bin/**/*' + - 'config/**/*' + - 'config.ru' + - 'db/**/*' + - 'vendor/**/*' + - .simplecov + +#### Bundler #### + +Bundler/OrderedGems: + Enabled: false + +#### Layout #### + +Layout/DotPosition: + EnforcedStyle: trailing + +Layout/ExtraSpacing: + AllowForAlignment: true + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +#### Lint #### +Lint/AmbiguousBlockAssociation: + Exclude: + # https://github.com/rubocop/rubocop/issues/4222#issuecomment-290655562 + - 'spec/**/*' + +#### Metrics #### + +Metrics/BlockLength: + CountComments: false # count full line comments? + Max: 25 + AllowedMethods: + # By default, exclude the `#refine` method, as it tends to have larger + # associated blocks. + - refine + Exclude: + # Specs by nature tend to have lengthy, nested blocks + - '*.gemspec' + - 'spec/**/*' + +Metrics/ClassLength: + CountAsOne: + - array + - hash + - heredoc + +Metrics/MethodLength: + CountAsOne: + - array + - hash + - heredoc + +#### Performance #### + +Performance/TimesMap: + # Disabling. Using `Array.new` with a block is marginally more performant, but + # `n.times.map` is much more readable. The former can be used when n is large. + # https://stackoverflow.com/questions/41518896/why-does-rubocop-suggest-replacing-times-map-with-array-new + Enabled: false + +#### Rails #### + +Rails/SkipsModelValidations: + # We are leaving this cop enabled as a warning. + # Failures can be approved as needed during code review. + Enabled: true + +#### RSpec #### + +# See also the list of RSpec statements that we exempt from the block +# length cop, under Metrics/BlockLength above + +RSpec/DescribeClass: + Exclude: + - 'spec/lib/tasks/**/*' + +RSpec/DescribedClass: + SkipBlocks: true + +RSpec/ExampleLength: + Enabled: false + +RSpec/ExpectChange: + EnforcedStyle: block + +RSpec/ImplicitSubject: + EnforcedStyle: single_statement_only + +RSpec/MessageChain: + Enabled: false + +RSpec/MultipleExpectations: + Enabled: false + +RSpec/MultipleMemoizedHelpers: + Enabled: false + +RSpec/NestedGroups: + Enabled: false + +#### Style #### + +Style/Documentation: + Enabled: false + +Style/FrozenStringLiteralComment: + Exclude: + - 'spec/**/*' + +Style/StringLiterals: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/MethodCallWithArgsParentheses: + Description: 'Use parentheses for method calls with arguments.' + Enabled: true + AllowedMethods: + # Ignore Ruby keyword methods: + # https://rubystyle.guide/#methods-that-have-keyword-status-in-ruby + - require + - yield + # https://rubystyle.guide/#exceptions + - raise + # Ignore logging methods, as they are considered part of an internal DSL + # https://rubystyle.guide/#methods-that-are-part-of-an-internal-dsl + - debug + - info + - warn + - error + - fatal + # Ignore Rails DSL methods + - has_many + - has_one + - order + - redirect_to + - render + - reset_callbacks + - set_callback + - skip_callback + Exclude: + - 'spec/**/*' + - 'Gemfile' + - 'db/**/*' + - '*.gemspec' + +Style/MixinUsage: + Exclude: + - bin/* + +Style/RescueStandardError: + Enabled: false + +Style/SymbolArray: + MinSize: 4 diff --git a/.simplecov b/.simplecov new file mode 100644 index 00000000..2f52443f --- /dev/null +++ b/.simplecov @@ -0,0 +1,33 @@ +if ENV['CIRCLECI'] + SimpleCov.at_exit do + result_hash = SimpleCov.result.to_hash + + if result_hash.keys == ['Cucumber, RSpec'] + if SimpleCov.result.covered_percent < 100 + puts "=========== Lines missing coverage: ===========" + result_hash['Cucumber, RSpec']['coverage'].each do |file_name, file_lines| + file_lines.each_with_index { |val, index| puts "#{file_name}, #{index + 1}" if val == 0 } + end + end + end + end +end + +SimpleCov.start 'rails' do + add_filter '/vendor/' + add_filter '/.bundler/' + add_filter '/.nix-bundler/' + + # Exclude ActionCable base files if not customized + add_filter '/app/channels/application_cable/channel.rb' + add_filter '/app/channels/application_cable/connection.rb' + + # Optionally exclude base classes if they don't have much custom logic + # add_filter '/app/controllers/application_controller.rb' + add_filter '/app/helpers/application_helper.rb' + add_filter '/app/jobs/application_job.rb' + add_filter '/app/mailers/application_mailer.rb' + add_filter '/app/models/application_record.rb' + + merge_timeout 1800 +end diff --git a/Gemfile b/Gemfile index a72dc127..4730e8c7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" ruby "3.2.2" @@ -36,7 +38,7 @@ gem "jbuilder" # gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] +gem "tzinfo-data", platforms: %i[windows jruby] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false @@ -46,9 +48,11 @@ gem "bootsnap", require: false group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri windows ] + gem "debug", platforms: %i[mri windows] + gem "rubocop" gem "rspec-rails" + gem 'codeclimate-test-reporter' end group :development do @@ -66,4 +70,6 @@ group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] gem "capybara" gem "selenium-webdriver" + gem 'rspec_junit_formatter' + gem 'simplecov' end diff --git a/Gemfile.lock b/Gemfile.lock index 6e19695c..39b69259 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,8 +75,9 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.2) base64 (0.2.0) bigdecimal (3.1.8) bindex (0.8.1) @@ -92,6 +93,8 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + codeclimate-test-reporter (1.0.9) + simplecov (<= 0.13) concurrent-ruby (1.3.3) connection_pool (2.4.1) crass (1.0.6) @@ -100,6 +103,7 @@ GEM irb (~> 1.10) reline (>= 0.3.8) diff-lcs (1.5.1) + docile (1.1.5) drb (2.2.1) erubi (1.13.0) globalid (1.2.1) @@ -111,12 +115,15 @@ GEM activesupport (>= 6.0.0) railties (>= 6.0.0) io-console (0.7.2) - irb (1.13.1) + irb (1.14.0) rdoc (>= 4.0.0) reline (>= 0.4.2) jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) + json (2.7.2) + language_server-protocol (3.17.0.3) + logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -128,10 +135,10 @@ GEM marcel (1.0.4) matrix (0.4.2) mini_mime (1.1.5) - minitest (5.23.1) + minitest (5.24.1) msgpack (1.7.2) mutex_m (0.2.0) - net-imap (0.4.12) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) @@ -149,14 +156,18 @@ GEM racc (~> 1.4) nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) + parallel (1.25.1) + parser (3.3.4.0) + ast (~> 2.4.1) + racc pg (1.5.6) psych (5.1.2) stringio - public_suffix (5.0.5) + public_suffix (6.0.0) puma (6.4.2) nio4r (~> 2.0) racc (1.8.0) - rack (3.1.3) + rack (3.1.7) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -193,13 +204,14 @@ GEM rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) + rainbow (3.1.1) rake (13.2.1) rdoc (6.7.0) psych (>= 4.0.0) regexp_parser (2.9.2) reline (0.5.9) io-console (~> 0.5) - rexml (3.3.0) + rexml (3.3.2) strscan rspec-core (3.13.0) rspec-support (~> 3.13.0) @@ -218,12 +230,34 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.65.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) rubyzip (2.3.2) - selenium-webdriver (4.21.1) + selenium-webdriver (4.23.0) base64 (~> 0.2) + logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + simplecov (0.13.0) + docile (~> 1.1.0) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -237,25 +271,26 @@ GEM strscan (3.1.0) thor (1.3.1) timeout (0.4.1) - turbo-rails (2.0.5) + turbo-rails (2.0.6) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) webrick (1.8.1) - websocket (1.2.10) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.15) + zeitwerk (2.6.16) PLATFORMS aarch64-linux @@ -266,6 +301,7 @@ PLATFORMS DEPENDENCIES bootsnap capybara + codeclimate-test-reporter debug importmap-rails jbuilder @@ -273,7 +309,10 @@ DEPENDENCIES puma (>= 5.0) rails (~> 7.1.3, >= 7.1.3.4) rspec-rails + rspec_junit_formatter + rubocop selenium-webdriver + simplecov sprockets-rails stimulus-rails turbo-rails diff --git a/Rakefile b/Rakefile index 9a5ea738..d2a78aa2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# 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. diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d6726972..9aec2305 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb index 0ff5442f..8d6c2a1b 100644 --- a/app/channels/application_cable/connection.rb +++ b/app/channels/application_cable/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ApplicationCable class Connection < ActionCable::Connection::Base end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d12..7944f9f9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ApplicationController < ActionController::Base end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..15b06f0f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module ApplicationHelper end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index d394c3d1..bef39599 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c814..5cc63a0c 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base default from: "from@example.com" layout "mailer" diff --git a/app/models/application_record.rb b/app/models/application_record.rb index b63caeb8..08dc5379 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base primary_abstract_class end diff --git a/config/brakeman.yml b/config/brakeman.yml new file mode 100644 index 00000000..564ec864 --- /dev/null +++ b/config/brakeman.yml @@ -0,0 +1,5 @@ +--- +:no-separate-models: true +:skip_checks: +- CheckMassAssignment +- CheckModelAttributes \ No newline at end of file diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb new file mode 100644 index 00000000..c78b0d5d --- /dev/null +++ b/spec/controllers/application_controller_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe ApplicationController do + it 'instantiates the controller' do + expect(described_class.new).to be_a(described_class) + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 00000000..a15455f3 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,65 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +# 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. +# +# Rails.root.glob('spec/support/**/*.rb').sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + abort e.to_s.strip +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_paths = [ + Rails.root.join('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 + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # 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://rspec.info/features/6-0/rspec-rails + 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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..9ef7f55e --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,15 @@ +require 'simplecov' +SimpleCov.command_name 'RSpec' + +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end + + config.shared_context_metadata_behavior = :apply_to_host_groups +end diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212ab..c05709af 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb index 6340bf9c..baa2e3fb 100644 --- a/test/channels/application_cable/connection_test.rb +++ b/test/channels/application_cable/connection_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" module ApplicationCable diff --git a/test/test_helper.rb b/test/test_helper.rb index 0c22470e..a64c49d4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ENV["RAILS_ENV"] ||= "test" require_relative "../config/environment" require "rails/test_help"