Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@
**/*Gemfile.lock
.ruby-version
.ruby-gemset

# Store gems for different ruby versions
.gems

# IDE
.idea
64 changes: 64 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[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 -- gem install bundler --no-document --conservative && \
mise x ruby@3.0 -- bundle install --gemfile gemfiles/activerecord-7.0.Gemfile --quiet && \
mise x ruby@3.0 -- bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rspec
'''
Comment thread
lmiglio marked this conversation as resolved.

# 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"]
run = "bundle exec --gemfile gemfiles/activerecord-7.0.Gemfile rspec"
Comment thread
lmiglio marked this conversation as resolved.
Outdated

# 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"
12 changes: 9 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Style/Documentation:
Style/RescueModifier:
Enabled: false

Style/SuperArguments:
Enabled: false

Lint/UselessConstantScoping:
Enabled: false

Layout/LineLength:
Exclude:
- spec/**/*_spec.rb
Expand All @@ -28,7 +34,7 @@ Metrics/MethodLength:
- 'array'
- 'hash'
- 'heredoc'
IgnoredMethods:
AllowedMethods:
- build_ghost_command
- mysql2_ghost_connection

Expand All @@ -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:
Expand Down
68 changes: 64 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions gemfiles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.gems/
2 changes: 1 addition & 1 deletion gemfiles/activerecord-7.0.Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'http://rubygems.org'

gem 'activerecord', '~> 7.0'
gem 'activerecord', '~> 7.0.0'

gemspec path: '../'