diff --git a/.gitignore b/.gitignore index 21646be..a8494bf 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,9 @@ **/*Gemfile.lock .ruby-version .ruby-gemset + +# Store gems for different ruby versions +.gems + +# IDE +.idea diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..556ad19 --- /dev/null +++ b/.mise.toml @@ -0,0 +1,69 @@ +[tools] +ruby = "3.3.10" + +[tasks.install] +alias = "i" +run = "bundle install --gemfile gemfiles/activerecord-7.0.Gemfile" + +[tasks.test] +run = "bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rspec" + +[tasks.console] +alias = "c" +run = "bin/console" + +[tasks.lint] +run = "bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rubocop -A" + +# Test with Ruby 2.7.8 (ActiveRecord 5.0, 5.1, 5.2 only) +[tasks."test:ruby27"] +env = { GEM_HOME = "{{config_root}}/.gems/ruby-2.7", GEM_PATH = "{{config_root}}/.gems/ruby-2.7" } +run = ''' + mise x ruby@2.7.8 -- gem install bundler --no-document --conservative && \ + mise x ruby@2.7.8 -- bundle install --gemfile gemfiles/activerecord-5.0.Gemfile --quiet && \ + mise x ruby@2.7.8 -- bundle exec --gemfile gemfiles/activerecord-5.0.Gemfile rspec && \ + mise x ruby@2.7.8 -- bundle install --gemfile gemfiles/activerecord-5.1.Gemfile --quiet && \ + mise x ruby@2.7.8 -- bundle exec --gemfile gemfiles/activerecord-5.1.Gemfile rspec && \ + mise x ruby@2.7.8 -- bundle install --gemfile gemfiles/activerecord-5.2.Gemfile --quiet && \ + mise x ruby@2.7.8 -- bundle exec --gemfile gemfiles/activerecord-5.2.Gemfile rspec +''' + +# Test with Ruby 3.0.2 (ActiveRecord 7.0 only - AR 6.1 has Logger compatibility issues) +[tasks."test:ruby30"] +env = { GEM_HOME = "{{config_root}}/.gems/ruby-3.0", GEM_PATH = "{{config_root}}/.gems/ruby-3.0" } +run = ''' + mise x ruby@3.0.2 -- gem install bundler --no-document --conservative && \ + mise x ruby@3.0.2 -- bundle install --gemfile gemfiles/activerecord-7.0.Gemfile --quiet && \ + mise x ruby@3.0.2 -- bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rspec +''' + +# Test with Ruby 3.1.7 (ActiveRecord 7.0 only - AR 6.1 has Logger compatibility issues) +[tasks."test:ruby31"] +env = { GEM_HOME = "{{config_root}}/.gems/ruby-3.1", GEM_PATH = "{{config_root}}/.gems/ruby-3.1" } +run = ''' + mise x ruby@3.1.7 -- gem install bundler --no-document --conservative && \ + mise x ruby@3.1.7 -- bundle install --gemfile gemfiles/activerecord-7.0.Gemfile --quiet && \ + mise x ruby@3.1.7 -- bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rspec +''' + +# Test with Ruby 3.2.9 (ActiveRecord 7.0 only - AR 6.1 has Logger compatibility issues) +[tasks."test:ruby32"] +env = { GEM_HOME = "{{config_root}}/.gems/ruby-3.2", GEM_PATH = "{{config_root}}/.gems/ruby-3.2" } +run = ''' + mise x ruby@3.2.9 -- gem install bundler --no-document --conservative && \ + mise x ruby@3.2.9 -- bundle install --gemfile gemfiles/activerecord-7.0.Gemfile --quiet && \ + mise x ruby@3.2.9 -- bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rspec +''' + +# Test with Ruby 3.3.10 (ActiveRecord 7.0 only - AR 6.1 has Logger compatibility issues) +[tasks."test:ruby33"] +env = { GEM_HOME = "{{config_root}}/.gems/ruby-3.3", GEM_PATH = "{{config_root}}/.gems/ruby-3.3" } +run = ''' + mise x ruby@3.3.10 -- gem install bundler --no-document --conservative && \ + mise x ruby@3.3.10 -- bundle install --gemfile gemfiles/activerecord-7.0.Gemfile --quiet && \ + mise x ruby@3.3.10 -- bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rspec +''' + +# Test all supported Ruby versions +[tasks."test:all"] +run = "mise run test:ruby27 && mise run test:ruby30 && mise run test:ruby31 && mise run test:ruby32 && mise run test:ruby33" \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index e125238..9ce3ee1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,6 +7,12 @@ Style/Documentation: Style/RescueModifier: Enabled: false +Style/SuperArguments: + Enabled: false + +Lint/UselessConstantScoping: + Enabled: false + Layout/LineLength: Exclude: - spec/**/*_spec.rb @@ -28,7 +34,7 @@ Metrics/MethodLength: - 'array' - 'hash' - 'heredoc' - IgnoredMethods: + AllowedMethods: - build_ghost_command - mysql2_ghost_connection @@ -41,12 +47,12 @@ Metrics/ModuleLength: - lib/ghost_adapter/config.rb Metrics/AbcSize: - IgnoredMethods: + AllowedMethods: - build_ghost_command - mysql2_ghost_connection Metrics/PerceivedComplexity: - IgnoredMethods: + AllowedMethods: - mysql2_ghost_connection AllCops: diff --git a/README.md b/README.md index d174ff2..d4764ca 100644 --- a/README.md +++ b/README.md @@ -62,15 +62,75 @@ If you have used the rails generator, you can set the variable to a falsey value - "truthy" values: `[1, t, true, y, yes]` - "falsey" values: `[0, f, false, n, no]` -### Running tests +## Local Development -To run the tests for all versions, run this script: +This project uses [mise](https://mise.jdx.dev/) to manage Ruby versions and development tasks. + +### Prerequisites + +Install mise: ```shell -bin/test_all_versions +# macOS +brew install mise + +# Other platforms: https://mise.jdx.dev/getting-started.html ``` -Make sure to use the appropriate Ruby version! ActiveRecord <6.0 is not compatible with Ruby 3, so specs for those versions will only run successfully in a Ruby 2 environment. +Activate mise in your shell (add to your `~/.bashrc` or `~/.zshrc`): + +```shell +eval "$(mise activate bash)" # or zsh, fish, etc. +``` + +### Getting Started + +Once mise is installed, it will automatically install and use the correct Ruby version when you enter the project directory. + +Install dependencies: + +```shell +mise run install +# or +mise run i +``` + +### Running Tests + +Run tests with the default Ruby version (3.3.10): + +```shell +mise run test +``` + +Run tests for a specific Ruby version: + +```shell +mise run test:ruby27 # Ruby 2.7.8 with ActiveRecord 5.0, 5.1, 5.2 +mise run test:ruby30 # Ruby 3.0.2 with ActiveRecord 7.0 +mise run test:ruby31 # Ruby 3.1.7 with ActiveRecord 7.0 +mise run test:ruby32 # Ruby 3.2.9 with ActiveRecord 7.0 +mise run test:ruby33 # Ruby 3.3.10 with ActiveRecord 7.0 +``` + +Run tests for all Ruby versions: + +```shell +mise run test:all +``` + +### Other Tasks + +```shell +mise run lint # Run rubocop with auto-correct +mise run console # Open console (also: mise run c) +``` + +View all available tasks: + +```shell +mise tasks +``` ## Contributing diff --git a/gemfiles/.gitignore b/gemfiles/.gitignore new file mode 100644 index 0000000..97886e2 --- /dev/null +++ b/gemfiles/.gitignore @@ -0,0 +1 @@ +.gems/ diff --git a/gemfiles/activerecord-7.0.Gemfile b/gemfiles/activerecord-7.0.Gemfile index e05f1bc..1e80ed4 100644 --- a/gemfiles/activerecord-7.0.Gemfile +++ b/gemfiles/activerecord-7.0.Gemfile @@ -1,5 +1,5 @@ source 'http://rubygems.org' -gem 'activerecord', '~> 7.0' +gem 'activerecord', '~> 7.0.0' gemspec path: '../'