Skip to content

Commit

Permalink
Add Ruby 3.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSouthan committed Feb 5, 2025
1 parent eac9e4e commit 47aa43e
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 110 deletions.
32 changes: 12 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ["3.0", "3.1", "3.2", "3.3"]
ruby-version: ["3.1", "3.2", "3.3", "3.4"]
rails-version:
- "6.1.7.6"
- "7.0.8"
- "7.1.1"
- "7.0"
- "7.1"
- "7.2"
- "8.0"
- "main"
postgres-version: ["12", "13", "14", "15", "16"]
exclude:
- ruby-version: "3.2"
rails-version: "6.1.7.6"
- ruby-version: "3.3"
rails-version: "6.1.7.6"
postgres-version: ["13", "14", "15", "16", "17"]
runs-on: ubuntu-latest
services:
postgres:
Expand Down Expand Up @@ -69,18 +65,14 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ["3.0", "3.1", "3.2", "3.3"]
ruby-version: ["3.1", "3.2", "3.3", "3.4"]
rails-version:
- "6.1.7.6"
- "7.0.8"
- "7.1.1"
- "7.0"
- "7.1"
- "7.2"
- "8.0"
- "main"
mysql-version: ["8.0", "8.2"]
exclude:
- ruby-version: "3.2"
rails-version: "6.1.7.6"
- ruby-version: "3.3"
rails-version: "6.1.7.6"
mysql-version: ["8.0", "8.4"]
runs-on: ubuntu-latest
services:
mysql:
Expand Down
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--require spec_helper
--format progress
5 changes: 1 addition & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inherit_gem:
gc_ruboconfig: rubocop.yml

AllCops:
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
NewCops: enable

Metrics/AbcSize:
Expand All @@ -15,6 +15,3 @@ Metrics/CyclomaticComplexity:

Metrics/PerceivedComplexity:
Max: 11

Gemspec/DevelopmentDependencies:
Enabled: false
48 changes: 7 additions & 41 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,28 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2021-08-09 15:32:40 UTC using RuboCop version 1.18.4.
# on 2025-02-05 15:31:48 UTC using RuboCop version 1.71.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'statesman.gemspec'

# Offense count: 1
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
- 'lib/statesman/adapters/active_record_queries.rb'

# Offense count: 5
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 20

# Offense count: 1
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 14

# Offense count: 11
# Offense count: 15
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 14

# Offense count: 7
# Offense count: 5
RSpec/ExpectInHook:
Exclude:
- 'spec/statesman/adapters/active_record_spec.rb'
- 'spec/statesman/machine_spec.rb'

# Offense count: 1
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/SpecFilePathFormat:
Exclude:
- 'spec/statesman/exceptions_spec.rb'

# Offense count: 1
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Expand Down Expand Up @@ -80,11 +52,12 @@ RSpec/MessageSpies:
Exclude:
- 'spec/statesman/callback_spec.rb'

# Offense count: 14
# Offense count: 20
RSpec/MultipleExpectations:
Max: 3

# Offense count: 49
# Offense count: 64
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 6

Expand All @@ -93,13 +66,6 @@ RSpec/RepeatedExampleGroupBody:
Exclude:
- 'spec/statesman/exceptions_spec.rb'

# Offense count: 12
RSpec/ScatteredSetup:
Exclude:
- 'spec/statesman/adapters/active_record_spec.rb'
- 'spec/statesman/adapters/shared_examples.rb'
- 'spec/statesman/machine_spec.rb'

# Offense count: 7
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.4.1
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Changelog

<!-- markdownlint-disable no-duplicate-heading -->

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v13.0.0 5th February 2024

### Changes

- Remove support for Rails < 7, add support for Rails 8
- Remove support for PostgreSQL < 12, add support for PostgreSQL 17
- Remove support for Ruby < 3.0, add support for Ruby 3.4

## v12.1.0 5th January 2024

### Fixed
Expand Down Expand Up @@ -154,7 +163,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix `to_s` on `TransitionFailedError` & `GuardFailedError`. `.message` and
`.to_s` diverged when `from` and `to` accessors where added in v4.1.3
`.to_s` diverged when `from` and `to` accessors where added in v4.1.3

## v7.0.1, 8th Jan 2020

Expand Down Expand Up @@ -258,7 +267,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixes an issue with `after_commit` transition blocks that where being
executed even if the transaction rolled back. ([patch](https://github.com/gocardless/statesman/pull/338) by [@matid](https://github.com/matid))
executed even if the transaction rolled back. ([patch](https://github.com/gocardless/statesman/pull/338) by [@matid](https://github.com/matid))

### Changed

Expand All @@ -269,8 +278,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Expose `most_recent_transition_join` - ActiveRecords `or` requires that both
sides of the query match up. Exposing this methods makes things easier if
one side of the `or` uses `in_state` or `not_in_state`. (patch by [@adambutler](https://github.com/adambutler))
sides of the query match up. Exposing this methods makes things easier if
one side of the `or` uses `in_state` or `not_in_state`. (patch by [@adambutler](https://github.com/adambutler))
- Various Readme and CI related changes.

## v3.4.1, 14 February 2018 ❤️
Expand Down Expand Up @@ -520,7 +529,7 @@ No changes from v1.0.0.beta2
### Added

- Adds after_commit flag to after_transition for callbacks to be executed after the transaction has been
committed on the ActiveRecord adapter. These callbacks will still be executed on non transactional adapters.
committed on the ActiveRecord adapter. These callbacks will still be executed on non transactional adapters.

## v0.3.0, 20 February 2014

Expand Down
26 changes: 19 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@ source 'https://rubygems.org'

gemspec

if ENV['RAILS_VERSION'] == 'main'
gem "rails", git: "https://github.com/rails/rails", branch: "main"
elsif ENV['RAILS_VERSION']
gem "rails", "~> #{ENV['RAILS_VERSION']}"
end

group :development do
group :development, :test do
gem "ammeter", "~> 1.1"
gem "bundler", "~> 2"
gem "gc_ruboconfig", "~> 5.0.0"
gem "mysql2", ">= 0.4", "< 0.6"
gem "pg", ">= 0.18", "<= 1.6"
gem "pry"
gem "rake", "~> 13.2.1"
gem "rspec", "~> 3.1"
gem "rspec-github", "~> 3.0.0"
gem "rspec-its", "~> 1.1"
gem "rspec-rails", "~> 6.0"
gem "sqlite3", "~> 2.5.0"
gem "test-unit", "~> 3.3"
gem "timecop", "~> 0.9.1"

if ENV['RAILS_VERSION'] == 'main'
gem "rails", git: "https://github.com/rails/rails", branch: "main"
elsif ENV['RAILS_VERSION']
gem "rails", "~> #{ENV['RAILS_VERSION']}"
end
end
2 changes: 1 addition & 1 deletion lib/statesman/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Statesman
VERSION = "12.1.0"
VERSION = "13.0.0"
end
14 changes: 8 additions & 6 deletions spec/statesman/adapters/active_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,10 @@
let(:adapter) { described_class.new(transition_class, model, observer) }

context "with a previously looked up transition" do
before { adapter.create(:x, :y) }

before { adapter.last }
before do
adapter.create(:x, :y)
adapter.last
end

it "caches the transition" do
expect_any_instance_of(MyActiveRecordModel).
Expand Down Expand Up @@ -444,9 +445,10 @@
end

context "with a pre-fetched transition history" do
before { adapter.create(:x, :y) }

before { model.my_active_record_model_transitions.load_target }
before do
adapter.create(:x, :y)
model.my_active_record_model_transitions.load_target
end

it "doesn't query the database" do
expect(MyActiveRecordModelTransition).to_not receive(:connection)
Expand Down
7 changes: 4 additions & 3 deletions spec/statesman/adapters/shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@
describe "#last" do
subject { adapter.last }

before { adapter.create(:x, :y) }

before { adapter.create(:y, :z) }
before do
adapter.create(:x, :y)
adapter.create(:y, :z)
end

it { is_expected.to be_a(transition_class) }
specify { expect(adapter.last.to_state.to_sym).to eq(:z) }
Expand Down
17 changes: 9 additions & 8 deletions spec/statesman/machine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
let(:my_model) { Class.new { attr_accessor :current_state }.new }

describe ".state" do
before { machine.state(:x) }

before { machine.state(:y) }
before do
machine.state(:x)
machine.state(:y)
end

specify { expect(machine.states).to eq(%w[x y]) }

Expand Down Expand Up @@ -610,9 +611,10 @@ def after_initialize; end
end

context "with multiple transitions" do
before { instance.transition_to!(:y) }

before { instance.transition_to!(:z) }
before do
instance.transition_to!(:y)
instance.transition_to!(:z)
end

it { is_expected.to eq("z") }
end
Expand All @@ -627,12 +629,11 @@ def after_initialize; end
state :y
transition from: :x, to: :y
end
instance.transition_to!(:y)
end

let(:instance) { machine.new(my_model) }

before { instance.transition_to!(:y) }

context "when machine is in given state" do
let(:state) { "y" }

Expand Down
22 changes: 8 additions & 14 deletions statesman.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.required_ruby_version = ">= 3.0"
spec.required_ruby_version = ">= 3.1"

spec.add_development_dependency "ammeter", "~> 1.1"
spec.add_development_dependency "bundler", "~> 2"
spec.add_development_dependency "gc_ruboconfig", "~> 5.0.0"
spec.add_development_dependency "mysql2", ">= 0.4", "< 0.6"
spec.add_development_dependency "pg", ">= 0.18", "<= 1.6"
spec.add_development_dependency "rails", ">= 5.2"
spec.add_development_dependency "rake", "~> 13.2.1"
spec.add_development_dependency "rspec", "~> 3.1"
spec.add_development_dependency "rspec-github", "~> 2.4.0"
spec.add_development_dependency "rspec-its", "~> 1.1"
spec.add_development_dependency "rspec-rails", "~> 6.0"
spec.add_development_dependency "sqlite3", "~> 1.7.0"
spec.add_development_dependency "timecop", "~> 0.9.1"
if ENV["RAILS_VERSION"] == "main"
gem "rails", git: "https://github.com/rails/rails", branch: "main"
elsif ENV["RAILS_VERSION"]
gem "rails", "~> #{ENV['RAILS_VERSION']}"
else
gem "rails", ">= 7.0"
end

spec.metadata = {
"bug_tracker_uri" => "#{GITHUB_URL}/issues",
Expand Down

0 comments on commit 47aa43e

Please sign in to comment.