From a4e33bf9c35b9c77a55824a30077c1b085b3fd1a Mon Sep 17 00:00:00 2001 From: Adam Fisher Date: Tue, 4 Aug 2026 14:19:15 +0000 Subject: [PATCH] Adopt .tool-versions and standardise script/setup for ruby script/setup ran `gem install bundler` under set -vx. It now runs `bundle install`. bundler has shipped as a default gem since Ruby 2.6. - Add .tool-versions pinning ruby 3.4 - Delete .ruby-version, superseded by .tool-versions - script/test uses set -euo pipefail and bundle exec - Update README to the standard template Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ruby/.ruby-version | 1 - ruby/.tool-versions | 1 + ruby/README.md | 27 +++++++++++++++++++++------ ruby/script/setup | 6 +++--- ruby/script/test | 6 ++++-- 5 files changed, 29 insertions(+), 12 deletions(-) delete mode 100644 ruby/.ruby-version create mode 100644 ruby/.tool-versions diff --git a/ruby/.ruby-version b/ruby/.ruby-version deleted file mode 100644 index 84d6c67..0000000 --- a/ruby/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.4.10 diff --git a/ruby/.tool-versions b/ruby/.tool-versions new file mode 100644 index 0000000..380cf51 --- /dev/null +++ b/ruby/.tool-versions @@ -0,0 +1 @@ +ruby 3.4 diff --git a/ruby/README.md b/ruby/README.md index 77e4577..5a3fcd7 100644 --- a/ruby/README.md +++ b/ruby/README.md @@ -1,17 +1,32 @@ # Ruby -Pairing test starter project for Ruby with rspec for testing. +Skeleton project for Ruby. + +## Prerequisites + +The toolchain this project needs is declared in [`.tool-versions`](./.tool-versions): + +``` +ruby 3.4 +``` + +Install those however you prefer, as long as they end up on your `PATH`. The quickest route is +[mise](https://mise.jdx.dev/), which reads the file for you: + +```sh +mise install +``` ## Usage -- `./script/setup` to install dependencies +- `./script/setup` to fetch dependencies - `./script/test` to run the tests -- `./script/start` to run the code +- `./script/start` to run the app - `./script/console` for an interactive prompt ## Structure -- Code located in [pairing_test.rb](./lib/pairing_test.rb) -- Tests located in [pairing_test_spec.rb](./spec/pairing_test_spec.rb) +- Code located in [`pairing_test.rb`](./lib/pairing_test.rb) +- Tests located in [`pairing_test_spec.rb`](./spec/pairing_test_spec.rb) `lib` has been added to the `require` path so all imports inside the `lib` directory must be relative to this, e.g. `require "pairing_test/version"`. -However, you're free to organise your code as you like. +However, you're free to organise your code as you like. diff --git a/ruby/script/setup b/ruby/script/setup index 1ba28af..29df332 100755 --- a/ruby/script/setup +++ b/ruby/script/setup @@ -1,7 +1,7 @@ #!/usr/bin/env bash + set -euo pipefail -IFS=$'\n\t' -set -vx -gem install bundler +cd "$(dirname "${BASH_SOURCE[0]}")/.." + bundle install diff --git a/ruby/script/test b/ruby/script/test index 2d784f2..5cafbd0 100755 --- a/ruby/script/test +++ b/ruby/script/test @@ -1,5 +1,7 @@ #!/usr/bin/env bash -set -e +set -euo pipefail -rake spec +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +bundle exec rake spec