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

Add csv and logger gems to remove warnings #308

Merged
merged 8 commits into from
Sep 23, 2024
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
9 changes: 8 additions & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:

- uses: actions/checkout@v4

- name: Restore node_modules
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.5'
Expand All @@ -74,4 +80,5 @@ jobs:
bin/rails db:test:prepare

- name: "Run Rspec"
run: bundle exec rspec
run: time bundle exec rspec --backtrace --force-color --format documentation

3 changes: 2 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
--format progress
--force-color
--color
--order rand
--profile 5
--profile 3
--require rails_helper
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ gem 'cssbundling-rails'
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem 'jbuilder'

# Gems that used to be in Standard Library, but are no longer
gem 'csv' # removed from stdlib with ruby 3.4
gem 'logger' # removed from stdlib with ruby 3.5

# Redis
gem 'redis' # , '>= 4.0.1'

Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ GEM
crass (1.0.6)
cssbundling-rails (1.4.1)
railties (>= 6.0.0)
csv (3.3.0)
dalli (3.2.8)
data_migrate (11.0.0)
activerecord (>= 6.1)
Expand Down Expand Up @@ -200,6 +201,7 @@ GEM
railties (>= 6.0.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.1)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
Expand Down Expand Up @@ -478,6 +480,7 @@ DEPENDENCIES
colorize
country_select
cssbundling-rails
csv
dalli
data_migrate
debug
Expand All @@ -492,6 +495,7 @@ DEPENDENCIES
hashie
jbuilder
jsbundling-rails
logger
lograge
logstash-event
mini_magick
Expand Down
7 changes: 0 additions & 7 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

require 'rspec/rails'
require 'accept_values_for'
require 'timeout'

def example_with_timeout(example)
Timeout.timeout(30) { example.run }
end

RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
Expand All @@ -25,8 +20,6 @@ def example_with_timeout(example)
Ventable.enable
end

config.around { |example| example_with_timeout(example) }

config.use_transactional_fixtures = true

config.expect_with(:rspec) do |c|
Expand Down
14 changes: 12 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# frozen_string_literal: true

ENV['RAILS_ENV'] = 'test'

$stdout.sync = true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so that if RSpec hangs on Github Action, we see which one.

$stderr.sync = true

# Enable YJIT if we have it compiled in
if defined?(RubyVM::YJIT) && RubyVM::YJIT.respond_to?(:enable)
RubyVM::YJIT.enable
Expand All @@ -8,8 +13,6 @@
warn '[ 𐄂 ] YJIT is not enabled'
end

ENV['RAILS_ENV'] = 'test'

require 'simplecov'
SimpleCov.start 'rails'

Expand All @@ -22,4 +25,11 @@
config.expect_with(:rspec) do |c|
c.syntax = %i[should expect]
end

config.around do |example|
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good to have this in spec_helper.rb and apply to all specs. Even 10 seconds is extremely generous.

# 10 seconds should be more than enough for ANY spec
Timeout.timeout(ENV.fetch('RSPEC_TIMEOUT', 10).to_i) do
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow eg CI to override the timeout if necessary.

example.run
end
end
end