From a6e87bb3c17b0dad4d6057f358b609df274f2c19 Mon Sep 17 00:00:00 2001 From: Adrian Ferrera Date: Wed, 17 Jun 2026 13:02:54 +0100 Subject: [PATCH] chore: upgrade Ruby 3.4, RSpec 3.13, add RuboCop; remove ActiveSupport and Guard --- .rspec | 1 + .rubocop.yml | 11 ++++++ .ruby-version | 2 +- Gemfile | 16 +++++--- Gemfile.lock | 76 -------------------------------------- Guardfile | 28 -------------- README.md | 15 ++++---- spec/spec_helper.rb | 89 +-------------------------------------------- sup/boot.rb | 14 +------ 9 files changed, 34 insertions(+), 218 deletions(-) create mode 100644 .rubocop.yml delete mode 100644 Gemfile.lock delete mode 100644 Guardfile diff --git a/.rspec b/.rspec index 83e16f8..43ae203 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --color --require spec_helper +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..d989114 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,11 @@ +AllCops: + NewCops: enable + TargetRubyVersion: 3.4 + Exclude: + - "vendor/**/*" + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Style/FrozenStringLiteralComment: + Enabled: true diff --git a/.ruby-version b/.ruby-version index 8bbe6cf..f989260 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.2 +3.4.4 diff --git a/Gemfile b/Gemfile index 6040e31..7dc43be 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,11 @@ -source 'https://rubygems.org' +# frozen_string_literal: true -gem 'rspec' -gem 'guard' -gem 'guard-rspec', require: false -gem 'terminal-notifier-guard', '~> 1.5.3' -gem 'activesupport', '>= 3.0.0', '< 5' \ No newline at end of file +source "https://rubygems.org" + +ruby "3.4.4" + +group :development, :test do + gem "rspec", "~> 3.13" + gem "rubocop", "~> 1.75", require: false + gem "rubocop-rspec", "~> 3.5", require: false +end diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 946cbc7..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,76 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (4.2.1) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - coderay (1.1.0) - diff-lcs (1.2.5) - ffi (1.9.9) - formatador (0.2.5) - guard (2.12.7) - formatador (>= 0.2.4) - listen (>= 2.7, <= 4.0) - lumberjack (~> 1.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.6.0) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - i18n (0.7.0) - json (1.8.1) - listen (3.0.1) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - lumberjack (1.0.9) - method_source (0.8.2) - minitest (5.6.0) - nenv (0.2.0) - notiffany (0.0.6) - nenv (~> 0.1) - shellany (~> 0.0) - pry (0.10.1) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - rb-fsevent (0.9.5) - rb-inotify (0.9.5) - ffi (>= 0.5.0) - rspec (3.3.0) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-core (3.3.1) - rspec-support (~> 3.3.0) - rspec-expectations (3.3.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-mocks (3.3.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-support (3.3.0) - shellany (0.0.1) - slop (3.6.0) - terminal-notifier-guard (1.5.3) - thor (0.19.1) - thread_safe (0.3.5) - tzinfo (1.2.2) - thread_safe (~> 0.1) - -PLATFORMS - ruby - -DEPENDENCIES - activesupport (>= 3.0.0, < 5) - guard - guard-rspec - rspec - terminal-notifier-guard (~> 1.5.3) diff --git a/Guardfile b/Guardfile deleted file mode 100644 index 055e0d4..0000000 --- a/Guardfile +++ /dev/null @@ -1,28 +0,0 @@ -# A sample Guardfile -# More info at https://github.com/guard/guard#readme - -## Uncomment and set this to only include directories you want to watch -# directories %w(app lib config test spec features) \ -# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} - -## Note: if you are using the `directories` clause above and you are not -## watching the project directory ('.'), then you will want to move -## the Guardfile to a watched dir and symlink it back, e.g. -# -# $ mkdir config -# $ mv Guardfile config/ -# $ ln -s config/Guardfile . -# -# and, you'll have to watch "config/Guardfile" instead of "Guardfile" - - -guard :rspec, { - :cmd => 'bundle exec rspec --color', - :all_after_pass => false, - :all_on_start => false, - :failed_mode => :keep -} do - watch('spec/spec_helper.rb') { "spec" } - watch(%r{^spec/.+\.rb}) { |m| m[0] } - watch(%r{^src/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" } -end \ No newline at end of file diff --git a/README.md b/README.md index 0484f45..47256f5 100644 --- a/README.md +++ b/README.md @@ -6,23 +6,19 @@ It takes care of: * Ruby version. * Loading gemfile dependencies. -* Class and module autoloading using activesupport. -* TDD enviroment using rspec and guard. +* Source loading for classes and modules. +* TDD enviroment using rspec. ## Working with the boilerplate **Clone** this repository: -`git clone https://github.com/platanus/ruby-dojo.git` +`git clone https://github.com/lean-mind/ruby-katas-template.git` Run **bundler**: `bundle install` -Start **guard**: - -`bundle exec guard` - Generate a **new class** or module with it corresponding **unit test**: `bundle exec ruby sup/generate.rb ClassName` @@ -31,8 +27,11 @@ Make sure to use `src/main.rb` as your app entry point and start application by `bundle exec ruby src/main.rb` -**IMPORTANT**: If you add new classes or modules by hand, make sure each file is named the same as the module/class it defines, so autoloading works properly. +Current baseline: +* Ruby 3.4.4 +* RSpec 3.13 +* RuboCop 1.75 with rubocop-rspec diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ab632c5..a7d360f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,98 +1,13 @@ -require File.expand_path('../../sup/boot.rb', __FILE__) +# frozen_string_literal: true -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. mocks.verify_partial_doubles = true end -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + config.shared_context_metadata_behavior = :apply_to_host_groups end diff --git a/sup/boot.rb b/sup/boot.rb index ee1238a..076106b 100644 --- a/sup/boot.rb +++ b/sup/boot.rb @@ -1,13 +1,3 @@ -require 'bundler' +# frozen_string_literal: true -# Load gems listed in the Gemfile. - -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__) -Bundler.setup - -# Setup code autoloading -APP_PATH = File.expand_path('../../', __FILE__) - -require 'active_support/dependencies' -ActiveSupport::Dependencies.autoload_paths += Dir.glob File.join(APP_PATH, 'src') -ActiveSupport::Dependencies.mechanism = :require +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "src"))