statesman 12.1.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d49f534086023febd344f7eb73b162903a28e3fd77ee430856d42242aafda37c
4
- data.tar.gz: aba9670be235de98143f0a2ae0d15b9b7b32c8a9699901049e5cd9d931e29981
3
+ metadata.gz: b15bf5cd57e2049db1ae4a0e93f41b16528c8a73c5741cf6337ec280f6ed1041
4
+ data.tar.gz: 28fba6b8a3304b97fb97a56d145243b5da73f79057fc05449dd3c48a6ea76f72
5
5
  SHA512:
6
- metadata.gz: d68959bd95e90bd0a986de5dd7197d21ac5535a5500d5d528b599fd07d26611125ce7e926f33efb5140f2ecbffa1c78dbb66e6d5f2209eeabe95ee49a4a862f8
7
- data.tar.gz: 449e98a18f512eaff9a1ea500f9415b016bc8e775f7e1b1a7b9ffc393038112b3689ff4e7d364cbff9be6d23e3c4768d373dda3df7339249b53aa7a9d2e33136
6
+ metadata.gz: 5df7c20cbbc737fc8527d959ad8d894cc0e5fece227099287dc1a96d72cbc62000d5d87b854f4a8483b2ee58c726154d9d50ca7568be27fc4126afe5a94818e5
7
+ data.tar.gz: 29c4efb1b93e7057ba343b8c4894978e3d9660a53043755f8d26e6378fa804085cd83e8d81203ab7f81a2cbcdd89bab5126042a113d9bb0ca376cb5967b65ba3
@@ -0,0 +1,31 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
+ {
4
+ "name": "Ruby",
5
+ "dockerComposeFile": "docker-compose.yml",
6
+ "service": "ruby",
7
+ "workspaceFolder": "/workspace",
8
+ // Environment variables for database connections
9
+ "containerEnv": {
10
+ "POSTGRES_URL": "postgresql://postgres:password@postgres:5432/statesman_dev",
11
+ "MYSQL_URL": "mysql2://root:password@mysql:3306/statesman_dev",
12
+ "PGHOST": "postgres",
13
+ "PGPORT": "5432",
14
+ "PGDATABASE": "statesman_dev",
15
+ "PGUSER": "postgres",
16
+ "PGPASSWORD": "password",
17
+ "MYSQL_HOST": "mysql",
18
+ "MYSQL_PORT": "3306",
19
+ "MYSQL_DATABASE": "statesman_dev",
20
+ "MYSQL_USER": "root",
21
+ "MYSQL_PASSWORD": "password"
22
+ },
23
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
24
+ // "forwardPorts": [],
25
+ // Use 'postCreateCommand' to run commands after the container is created.
26
+ "postCreateCommand": "sudo apt-get update && sudo apt-get install -y postgresql-client default-mysql-client && sudo chown -R vscode:vscode /usr/local/rvm/gems/default && bundle install",
27
+ // Configure tool-specific properties.
28
+ // "customizations": {},
29
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
30
+ // "remoteUser": "root"
31
+ }
@@ -0,0 +1,39 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ ruby:
5
+ image: mcr.microsoft.com/devcontainers/ruby:1-3.4-bullseye
6
+ volumes:
7
+ - ..:/workspace:cached
8
+ - gem-cache:/usr/local/rvm/gems/default
9
+ command: sleep infinity
10
+ depends_on:
11
+ - postgres
12
+ - mysql
13
+
14
+ postgres:
15
+ image: postgres:15
16
+ restart: unless-stopped
17
+ environment:
18
+ POSTGRES_PASSWORD: password
19
+ POSTGRES_DB: statesman_dev
20
+ volumes:
21
+ - postgres-data:/var/lib/postgresql/data
22
+ expose:
23
+ - "5432"
24
+
25
+ mysql:
26
+ image: mysql:8.0
27
+ restart: unless-stopped
28
+ environment:
29
+ MYSQL_ROOT_PASSWORD: password
30
+ MYSQL_DATABASE: statesman_dev
31
+ volumes:
32
+ - mysql-data:/var/lib/mysql
33
+ expose:
34
+ - "3306"
35
+
36
+ volumes:
37
+ postgres-data:
38
+ mysql-data:
39
+ gem-cache:
@@ -3,8 +3,9 @@ name: tests
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - "master"
6
+ - master
7
7
  pull_request:
8
+ types: [opened, reopened, synchronize]
8
9
 
9
10
  concurrency:
10
11
  group: ${{ github.workflow }}-${{ github.ref }}
@@ -14,28 +15,47 @@ jobs:
14
15
  rubocop:
15
16
  runs-on: ubuntu-latest
16
17
  steps:
17
- - uses: actions/checkout@v3
18
+ - uses: actions/checkout@v5
18
19
  - uses: ruby/setup-ruby@v1
19
20
  with:
20
21
  bundler-cache: true
21
22
  - run: bundle exec rubocop --extra-details --display-style-guide --parallel --force-exclusion
22
23
 
24
+ sqlite:
25
+ strategy:
26
+ fail-fast: false
27
+ matrix:
28
+ ruby-version: ["3.2", "3.3", "3.4", "3.5"]
29
+ rails-version:
30
+ - "7.1"
31
+ - "7.2"
32
+ - "8.0"
33
+ - "main"
34
+ runs-on: ubuntu-latest
35
+ env:
36
+ RAILS_VERSION: ${{ matrix.rails-version }}
37
+ steps:
38
+ - uses: actions/checkout@v5
39
+ - name: Set up Ruby
40
+ uses: ruby/setup-ruby@v1
41
+ with:
42
+ bundler-cache: true
43
+ ruby-version: "${{ matrix.ruby-version }}"
44
+ - name: Run specs
45
+ run: |
46
+ bundle exec rspec --profile --format progress --format RSpec::Github::Formatter
47
+
23
48
  postgres:
24
49
  strategy:
25
50
  fail-fast: false
26
51
  matrix:
27
- ruby-version: ["3.0", "3.1", "3.2", "3.3"]
52
+ ruby-version: ["3.2", "3.3", "3.4", "3.5"]
28
53
  rails-version:
29
- - "6.1.7.6"
30
- - "7.0.8"
31
- - "7.1.1"
54
+ - "7.1"
55
+ - "7.2"
56
+ - "8.0"
32
57
  - "main"
33
- postgres-version: ["12", "13", "14", "15", "16"]
34
- exclude:
35
- - ruby-version: "3.2"
36
- rails-version: "6.1.7.6"
37
- - ruby-version: "3.3"
38
- rails-version: "6.1.7.6"
58
+ postgres-version: ["14", "15", "16", "17"]
39
59
  runs-on: ubuntu-latest
40
60
  services:
41
61
  postgres:
@@ -54,8 +74,9 @@ jobs:
54
74
  env:
55
75
  DATABASE_URL: postgres://postgres:statesman@localhost/statesman_test
56
76
  DATABASE_DEPENDENCY_PORT: "5432"
77
+ RAILS_VERSION: ${{ matrix.rails-version }}
57
78
  steps:
58
- - uses: actions/checkout@v3
79
+ - uses: actions/checkout@v5
59
80
  - name: Set up Ruby
60
81
  uses: ruby/setup-ruby@v1
61
82
  with:
@@ -69,18 +90,14 @@ jobs:
69
90
  strategy:
70
91
  fail-fast: false
71
92
  matrix:
72
- ruby-version: ["3.0", "3.1", "3.2", "3.3"]
93
+ ruby-version: ["3.2", "3.3", "3.4", "3.5"]
73
94
  rails-version:
74
- - "6.1.7.6"
75
- - "7.0.8"
76
- - "7.1.1"
95
+ - "7.1"
96
+ - "7.2"
97
+ - "8.0"
77
98
  - "main"
78
- mysql-version: ["8.0", "8.2"]
79
- exclude:
80
- - ruby-version: "3.2"
81
- rails-version: "6.1.7.6"
82
- - ruby-version: "3.3"
83
- rails-version: "6.1.7.6"
99
+ mysql-version: ["8.0", "8.4", "9.4"]
100
+
84
101
  runs-on: ubuntu-latest
85
102
  services:
86
103
  mysql:
@@ -100,8 +117,9 @@ jobs:
100
117
  env:
101
118
  DATABASE_URL: mysql2://foobar:password@127.0.0.1/statesman_test
102
119
  DATABASE_DEPENDENCY_PORT: "3306"
120
+ RAILS_VERSION: ${{ matrix.rails-version }}
103
121
  steps:
104
- - uses: actions/checkout@v3
122
+ - uses: actions/checkout@v5
105
123
  - name: Set up Ruby
106
124
  uses: ruby/setup-ruby@v1
107
125
  with:
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --require spec_helper
2
+ --format progress
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ inherit_gem:
4
4
  gc_ruboconfig: rubocop.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 3.0
7
+ TargetRubyVersion: 3.2
8
8
  NewCops: enable
9
9
 
10
10
  Metrics/AbcSize:
@@ -15,6 +15,3 @@ Metrics/CyclomaticComplexity:
15
15
 
16
16
  Metrics/PerceivedComplexity:
17
17
  Max: 11
18
-
19
- Gemspec/DevelopmentDependencies:
20
- Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,56 +1,47 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-08-09 15:32:40 UTC using RuboCop version 1.18.4.
3
+ # on 2025-08-29 17:37:05 UTC using RuboCop version 1.80.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- # Configuration parameters: Include.
11
- # Include: **/*.gemspec
12
- Gemspec/RequiredRubyVersion:
13
- Exclude:
14
- - 'statesman.gemspec'
15
-
16
- # Offense count: 1
10
+ # Configuration parameters: AllowedParentClasses.
17
11
  Lint/MissingSuper:
18
12
  Exclude:
19
13
  - 'lib/statesman/adapters/active_record_queries.rb'
20
14
 
21
- # Offense count: 5
22
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
23
- Metrics/AbcSize:
24
- Max: 20
15
+ # Offense count: 2
16
+ # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
17
+ # AllowedMethods: call
18
+ # WaywardPredicates: nonzero?
19
+ Naming/PredicateMethod:
20
+ Exclude:
21
+ - 'lib/statesman/callback.rb'
25
22
 
26
23
  # Offense count: 1
27
- # Configuration parameters: IgnoredMethods.
28
- Metrics/CyclomaticComplexity:
29
- Max: 8
30
-
31
- # Offense count: 3
32
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
33
- Metrics/MethodLength:
34
- Max: 14
24
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
25
+ # NamePrefix: is_, has_, have_, does_
26
+ # ForbiddenPrefixes: is_, has_, have_, does_
27
+ # AllowedMethods: is_a?
28
+ # MethodDefinitionMacros: define_method, define_singleton_method
29
+ Naming/PredicatePrefix:
30
+ Exclude:
31
+ - 'spec/**/*'
32
+ - 'lib/statesman/adapters/active_record.rb'
35
33
 
36
- # Offense count: 11
34
+ # Offense count: 15
37
35
  # Configuration parameters: CountAsOne.
38
36
  RSpec/ExampleLength:
39
37
  Max: 14
40
38
 
41
- # Offense count: 7
39
+ # Offense count: 5
42
40
  RSpec/ExpectInHook:
43
41
  Exclude:
44
42
  - 'spec/statesman/adapters/active_record_spec.rb'
45
43
  - 'spec/statesman/machine_spec.rb'
46
44
 
47
- # Offense count: 1
48
- # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
49
- # Include: **/*_spec*rb*, **/spec/**/*
50
- RSpec/FilePath:
51
- Exclude:
52
- - 'spec/statesman/exceptions_spec.rb'
53
-
54
45
  # Offense count: 1
55
46
  # Configuration parameters: AssignmentOnly.
56
47
  RSpec/InstanceVariable:
@@ -80,11 +71,12 @@ RSpec/MessageSpies:
80
71
  Exclude:
81
72
  - 'spec/statesman/callback_spec.rb'
82
73
 
83
- # Offense count: 14
74
+ # Offense count: 20
84
75
  RSpec/MultipleExpectations:
85
76
  Max: 3
86
77
 
87
- # Offense count: 49
78
+ # Offense count: 64
79
+ # Configuration parameters: AllowedGroups.
88
80
  RSpec/NestedGroups:
89
81
  Max: 6
90
82
 
@@ -93,13 +85,6 @@ RSpec/RepeatedExampleGroupBody:
93
85
  Exclude:
94
86
  - 'spec/statesman/exceptions_spec.rb'
95
87
 
96
- # Offense count: 12
97
- RSpec/ScatteredSetup:
98
- Exclude:
99
- - 'spec/statesman/adapters/active_record_spec.rb'
100
- - 'spec/statesman/adapters/shared_examples.rb'
101
- - 'spec/statesman/machine_spec.rb'
102
-
103
88
  # Offense count: 7
104
89
  # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
105
90
  RSpec/VerifiedDoubles:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.4.5
data/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # Changelog
2
+
2
3
  <!-- markdownlint-disable no-duplicate-heading -->
3
4
 
4
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
7
 
8
+ ## v13.0.0 29th August 2025
9
+
10
+ ### Changes
11
+
12
+ - Remove support for Rails 6.1 and 7, add support for Rails 8
13
+ - Remove support for PostgreSQL < 13, add support for PostgreSQL 17
14
+ - Remove support for Ruby 3.0, 3.1, add support for Ruby 3.4 and 3.5
15
+
7
16
  ## v12.1.0 5th January 2024
8
17
 
9
18
  ### Fixed
@@ -44,7 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
44
53
 
45
54
  ### Changed
46
55
 
47
- - Calling `active_record.reload` resets the adapater's internal cache
56
+ - Calling `active_record.reload` resets the adapter's internal cache
48
57
 
49
58
  ## v10.2.1 3rd April 2023
50
59
 
@@ -154,7 +163,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
154
163
  ### Fixed
155
164
 
156
165
  - Fix `to_s` on `TransitionFailedError` & `GuardFailedError`. `.message` and
157
- `.to_s` diverged when `from` and `to` accessors where added in v4.1.3
166
+ `.to_s` diverged when `from` and `to` accessors where added in v4.1.3
158
167
 
159
168
  ## v7.0.1, 8th Jan 2020
160
169
 
@@ -258,7 +267,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
258
267
  ### Fixed
259
268
 
260
269
  - Fixes an issue with `after_commit` transition blocks that where being
261
- executed even if the transaction rolled back. ([patch](https://github.com/gocardless/statesman/pull/338) by [@matid](https://github.com/matid))
270
+ executed even if the transaction rolled back. ([patch](https://github.com/gocardless/statesman/pull/338) by [@matid](https://github.com/matid))
262
271
 
263
272
  ### Changed
264
273
 
@@ -269,8 +278,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
269
278
  ### Changed
270
279
 
271
280
  - Expose `most_recent_transition_join` - ActiveRecords `or` requires that both
272
- sides of the query match up. Exposing this methods makes things easier if
273
- one side of the `or` uses `in_state` or `not_in_state`. (patch by [@adambutler](https://github.com/adambutler))
281
+ sides of the query match up. Exposing this methods makes things easier if
282
+ one side of the `or` uses `in_state` or `not_in_state`. (patch by [@adambutler](https://github.com/adambutler))
274
283
  - Various Readme and CI related changes.
275
284
 
276
285
  ## v3.4.1, 14 February 2018 ❤️
@@ -450,7 +459,7 @@ No changes from v1.0.0.beta2
450
459
 
451
460
  ### Fixed
452
461
 
453
- - `ActiveRecordModel.in_state` and `ActiveRecordModel.not_in_state` now handle inital states correctly (patch by [@isaacseymour](https://github.com/isaacseymour))
462
+ - `ActiveRecordModel.in_state` and `ActiveRecordModel.not_in_state` now handle initial states correctly (patch by [@isaacseymour](https://github.com/isaacseymour))
454
463
 
455
464
  ### Added
456
465
 
@@ -520,7 +529,7 @@ No changes from v1.0.0.beta2
520
529
  ### Added
521
530
 
522
531
  - Adds after_commit flag to after_transition for callbacks to be executed after the transaction has been
523
- committed on the ActiveRecord adapter. These callbacks will still be executed on non transactional adapters.
532
+ committed on the ActiveRecord adapter. These callbacks will still be executed on non transactional adapters.
524
533
 
525
534
  ## v0.3.0, 20 February 2014
526
535
 
data/Gemfile CHANGED
@@ -8,9 +8,23 @@ if ENV['RAILS_VERSION'] == 'main'
8
8
  gem "rails", git: "https://github.com/rails/rails", branch: "main"
9
9
  elsif ENV['RAILS_VERSION']
10
10
  gem "rails", "~> #{ENV['RAILS_VERSION']}"
11
+ else
12
+ gem "rails", "~> 8.0"
11
13
  end
12
14
 
13
- group :development do
15
+ group :development, :test do
16
+ gem "ammeter", "~> 1.1"
17
+ gem "bundler", "~> 2"
18
+ gem "gc_ruboconfig", "~> 5.0.0"
19
+ gem "mysql2", ">= 0.4", "< 0.6"
20
+ gem "pg", ">= 0.18", "<= 1.7"
14
21
  gem "pry"
22
+ gem "rake", "~> 13.3.0"
23
+ gem "rspec", "~> 3.1"
24
+ gem "rspec-github", "~> 3.0.0"
25
+ gem "rspec-its", "~> 2.0"
26
+ gem "rspec-rails", "~> 8.0"
27
+ gem "sqlite3", "~> 2.7.3"
15
28
  gem "test-unit", "~> 3.3"
29
+ gem "timecop", "~> 0.9.1"
16
30
  end
data/README.md CHANGED
@@ -256,6 +256,23 @@ ActiveRecord adapter.
256
256
 
257
257
  Statesman will fallback to memory unless you specify a transition_class when instantiating your state machine. This allows you to only persist transitions on certain state machines in your app.
258
258
 
259
+ ### `initial_transition`
260
+
261
+ ```ruby
262
+ def state_machine
263
+ @state_machine ||= OrderStateMachine.new(self, transition_class: OrderTransition,
264
+ association_name: :transitions,
265
+ initial_transition: true)
266
+ end
267
+ ```
268
+
269
+ By default Statesman does not record a transition to the initial state of the state machine.
270
+
271
+ You can configure Statesman to record a transition to the initial state, this will allow you to:
272
+ - Keep an accurate record of the initial state even if configuration changes
273
+ - Keep a record of how long the state machine spent in the initial state
274
+ - Utilise a transition hook for the transition to the initial state
275
+
259
276
  ## Class methods
260
277
 
261
278
  ### `Machine.state`
@@ -494,7 +511,7 @@ Raised if:
494
511
  ### Runtime errors
495
512
 
496
513
  These errors are raised by `transition_to!`. Using `transition_to` will
497
- supress `GuardFailedError` and `TransitionFailedError` and return `false` instead.
514
+ suppress `GuardFailedError` and `TransitionFailedError` and return `false` instead.
498
515
 
499
516
  #### GuardFailedError
500
517
 
@@ -596,22 +613,6 @@ Given a field `foo` that was stored in the metadata, you can access it like so:
596
613
  model_instance.state_machine.last_transition.metadata["foo"]
597
614
  ```
598
615
 
599
- ### Events
600
-
601
- Used to using a state machine with "events"? Support for events is provided by
602
- the [statesman-events](https://github.com/gocardless/statesman-events) gem. Once
603
- that's included in your Gemfile you can include event functionality in your
604
- state machine as follows:
605
-
606
- ```ruby
607
- class OrderStateMachine
608
- include Statesman::Machine
609
- include Statesman::Events
610
-
611
- ...
612
- end
613
- ```
614
-
615
616
  ### Deleting records
616
617
 
617
618
  If you need to delete the Parent model regularly you will need to change
@@ -2,7 +2,7 @@
2
2
 
3
3
  Our goal as Statesman maintainers is for the library to be compatible with all supported versions of Ruby and Rails.
4
4
 
5
- Specifically, any CRuby/MRI version that has not received an End of Life notice ([e.g. this notice for Ruby 2.1](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/)) is supported. Similarly, any version of Rails listed as currently supported on [this page](http://guides.rubyonrails.org/maintenance_policy.html) is one we aim to support in Statesman.
5
+ Specifically, any CRuby/MRI version that has not received an [End of Life notice](https://endoflife.date/ruby)) is supported. Similarly, any version of Rails listed as currently supported on [this page](https://endoflife.date/rails) is one we aim to support in Statesman.
6
6
 
7
7
  To that end, [our build matrix](../.github/workflows/tests.yml) includes all these versions.
8
8
 
@@ -379,11 +379,9 @@ module Statesman
379
379
  true
380
380
  end
381
381
 
382
- # rubocop: disable Naming/PredicateName
383
382
  def has_transactional_callbacks?
384
383
  true
385
384
  end
386
- # rubocop: enable Naming/PredicateName
387
385
 
388
386
  def committed!(*)
389
387
  @callback.call
@@ -6,7 +6,7 @@ require_relative "exceptions"
6
6
  module Statesman
7
7
  class Guard < Callback
8
8
  def call(*args)
9
- raise GuardFailedError.new(from, to, callback) unless super(*args)
9
+ raise GuardFailedError.new(from, to, callback) unless super
10
10
  end
11
11
  end
12
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Statesman
4
- VERSION = "12.1.0"
4
+ VERSION = "13.0.0"
5
5
  end
@@ -214,13 +214,13 @@ describe Statesman::Adapters::ActiveRecordQueries, :active_record do
214
214
  context "using old configuration method" do
215
215
  let(:config_type) { :old }
216
216
 
217
- include_examples "testing methods"
217
+ it_behaves_like "testing methods"
218
218
  end
219
219
 
220
220
  context "using new configuration method" do
221
221
  let(:config_type) { :new }
222
222
 
223
- include_examples "testing methods"
223
+ it_behaves_like "testing methods"
224
224
  end
225
225
 
226
226
  context "with no association with the transition class" do
@@ -375,9 +375,10 @@ describe Statesman::Adapters::ActiveRecord, :active_record do
375
375
  let(:adapter) { described_class.new(transition_class, model, observer) }
376
376
 
377
377
  context "with a previously looked up transition" do
378
- before { adapter.create(:x, :y) }
379
-
380
- before { adapter.last }
378
+ before do
379
+ adapter.create(:x, :y)
380
+ adapter.last
381
+ end
381
382
 
382
383
  it "caches the transition" do
383
384
  expect_any_instance_of(MyActiveRecordModel).
@@ -444,9 +445,10 @@ describe Statesman::Adapters::ActiveRecord, :active_record do
444
445
  end
445
446
 
446
447
  context "with a pre-fetched transition history" do
447
- before { adapter.create(:x, :y) }
448
-
449
- before { model.my_active_record_model_transitions.load_target }
448
+ before do
449
+ adapter.create(:x, :y)
450
+ model.my_active_record_model_transitions.load_target
451
+ end
450
452
 
451
453
  it "doesn't query the database" do
452
454
  expect(MyActiveRecordModelTransition).to_not receive(:connection)
@@ -120,9 +120,10 @@ shared_examples_for "an adapter" do |adapter_class, transition_class, options =
120
120
  describe "#last" do
121
121
  subject { adapter.last }
122
122
 
123
- before { adapter.create(:x, :y) }
124
-
125
- before { adapter.create(:y, :z) }
123
+ before do
124
+ adapter.create(:x, :y)
125
+ adapter.create(:y, :z)
126
+ end
126
127
 
127
128
  it { is_expected.to be_a(transition_class) }
128
129
  specify { expect(adapter.last.to_state.to_sym).to eq(:z) }
@@ -201,6 +201,6 @@ describe Statesman::Adapters::TypeSafeActiveRecordQueries, :active_record do
201
201
  end
202
202
 
203
203
  context "using configuration method" do
204
- include_examples "testing methods"
204
+ it_behaves_like "testing methods"
205
205
  end
206
206
  end
@@ -5,9 +5,10 @@ describe Statesman::Machine do
5
5
  let(:my_model) { Class.new { attr_accessor :current_state }.new }
6
6
 
7
7
  describe ".state" do
8
- before { machine.state(:x) }
9
-
10
- before { machine.state(:y) }
8
+ before do
9
+ machine.state(:x)
10
+ machine.state(:y)
11
+ end
11
12
 
12
13
  specify { expect(machine.states).to eq(%w[x y]) }
13
14
 
@@ -610,9 +611,10 @@ describe Statesman::Machine do
610
611
  end
611
612
 
612
613
  context "with multiple transitions" do
613
- before { instance.transition_to!(:y) }
614
-
615
- before { instance.transition_to!(:z) }
614
+ before do
615
+ instance.transition_to!(:y)
616
+ instance.transition_to!(:z)
617
+ end
616
618
 
617
619
  it { is_expected.to eq("z") }
618
620
  end
@@ -627,12 +629,11 @@ describe Statesman::Machine do
627
629
  state :y
628
630
  transition from: :x, to: :y
629
631
  end
632
+ instance.transition_to!(:y)
630
633
  end
631
634
 
632
635
  let(:instance) { machine.new(my_model) }
633
636
 
634
- before { instance.transition_to!(:y) }
635
-
636
637
  context "when machine is in given state" do
637
638
  let(:state) { "y" }
638
639
 
@@ -995,7 +996,7 @@ describe Statesman::Machine do
995
996
  let(:instance) { machine.new(my_model) }
996
997
  let(:metadata) { { some: :metadata } }
997
998
 
998
- context "when it is succesful" do
999
+ context "when it is successful" do
999
1000
  before do
1000
1001
  expect(instance).to receive(:transition_to!).once.
1001
1002
  with(:some_state, metadata).and_return(:some_state)
@@ -32,7 +32,7 @@ class MyActiveRecordModel < ActiveRecord::Base
32
32
 
33
33
  include Statesman::Adapters::ActiveRecordQueries[
34
34
  transition_class: MyActiveRecordModelTransition,
35
- initial_state: :initial
35
+ initial_state: :initial,
36
36
  ]
37
37
 
38
38
  def state_machine
@@ -162,7 +162,7 @@ class SecondaryActiveRecordModel < SecondaryRecord
162
162
 
163
163
  include Statesman::Adapters::ActiveRecordQueries[
164
164
  transition_class: SecondaryActiveRecordModelTransition,
165
- initial_state: :initial
165
+ initial_state: :initial,
166
166
  ]
167
167
 
168
168
  def state_machine
data/statesman.gemspec CHANGED
@@ -20,21 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.required_ruby_version = ">= 3.0"
24
-
25
- spec.add_development_dependency "ammeter", "~> 1.1"
26
- spec.add_development_dependency "bundler", "~> 2"
27
- spec.add_development_dependency "gc_ruboconfig", "~> 4.4.1"
28
- spec.add_development_dependency "mysql2", ">= 0.4", "< 0.6"
29
- spec.add_development_dependency "pg", ">= 0.18", "<= 1.6"
30
- spec.add_development_dependency "rails", ">= 5.2"
31
- spec.add_development_dependency "rake", "~> 13.1.0"
32
- spec.add_development_dependency "rspec", "~> 3.1"
33
- spec.add_development_dependency "rspec-github", "~> 2.4.0"
34
- spec.add_development_dependency "rspec-its", "~> 1.1"
35
- spec.add_development_dependency "rspec-rails", "~> 6.0"
36
- spec.add_development_dependency "sqlite3", "~> 1.7.0"
37
- spec.add_development_dependency "timecop", "~> 0.9.1"
23
+ spec.required_ruby_version = ">= 3.2"
38
24
 
39
25
  spec.metadata = {
40
26
  "bug_tracker_uri" => "#{GITHUB_URL}/issues",
metadata CHANGED
@@ -1,209 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statesman
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.1.0
4
+ version: 13.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ammeter
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.1'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.1'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2'
41
- - !ruby/object:Gem::Dependency
42
- name: gc_ruboconfig
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 4.4.1
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 4.4.1
55
- - !ruby/object:Gem::Dependency
56
- name: mysql2
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0.4'
62
- - - "<"
63
- - !ruby/object:Gem::Version
64
- version: '0.6'
65
- type: :development
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '0.4'
72
- - - "<"
73
- - !ruby/object:Gem::Version
74
- version: '0.6'
75
- - !ruby/object:Gem::Dependency
76
- name: pg
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0.18'
82
- - - "<="
83
- - !ruby/object:Gem::Version
84
- version: '1.6'
85
- type: :development
86
- prerelease: false
87
- version_requirements: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: '0.18'
92
- - - "<="
93
- - !ruby/object:Gem::Version
94
- version: '1.6'
95
- - !ruby/object:Gem::Dependency
96
- name: rails
97
- requirement: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: '5.2'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: '5.2'
109
- - !ruby/object:Gem::Dependency
110
- name: rake
111
- requirement: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: 13.1.0
116
- type: :development
117
- prerelease: false
118
- version_requirements: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: 13.1.0
123
- - !ruby/object:Gem::Dependency
124
- name: rspec
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '3.1'
130
- type: :development
131
- prerelease: false
132
- version_requirements: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: '3.1'
137
- - !ruby/object:Gem::Dependency
138
- name: rspec-github
139
- requirement: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - "~>"
142
- - !ruby/object:Gem::Version
143
- version: 2.4.0
144
- type: :development
145
- prerelease: false
146
- version_requirements: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - "~>"
149
- - !ruby/object:Gem::Version
150
- version: 2.4.0
151
- - !ruby/object:Gem::Dependency
152
- name: rspec-its
153
- requirement: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - "~>"
156
- - !ruby/object:Gem::Version
157
- version: '1.1'
158
- type: :development
159
- prerelease: false
160
- version_requirements: !ruby/object:Gem::Requirement
161
- requirements:
162
- - - "~>"
163
- - !ruby/object:Gem::Version
164
- version: '1.1'
165
- - !ruby/object:Gem::Dependency
166
- name: rspec-rails
167
- requirement: !ruby/object:Gem::Requirement
168
- requirements:
169
- - - "~>"
170
- - !ruby/object:Gem::Version
171
- version: '6.0'
172
- type: :development
173
- prerelease: false
174
- version_requirements: !ruby/object:Gem::Requirement
175
- requirements:
176
- - - "~>"
177
- - !ruby/object:Gem::Version
178
- version: '6.0'
179
- - !ruby/object:Gem::Dependency
180
- name: sqlite3
181
- requirement: !ruby/object:Gem::Requirement
182
- requirements:
183
- - - "~>"
184
- - !ruby/object:Gem::Version
185
- version: 1.7.0
186
- type: :development
187
- prerelease: false
188
- version_requirements: !ruby/object:Gem::Requirement
189
- requirements:
190
- - - "~>"
191
- - !ruby/object:Gem::Version
192
- version: 1.7.0
193
- - !ruby/object:Gem::Dependency
194
- name: timecop
195
- requirement: !ruby/object:Gem::Requirement
196
- requirements:
197
- - - "~>"
198
- - !ruby/object:Gem::Version
199
- version: 0.9.1
200
- type: :development
201
- prerelease: false
202
- version_requirements: !ruby/object:Gem::Requirement
203
- requirements:
204
- - - "~>"
205
- - !ruby/object:Gem::Version
206
- version: 0.9.1
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
207
12
  description: A statesman-like state machine library
208
13
  email:
209
14
  - developers@gocardless.com
@@ -211,6 +16,8 @@ executables: []
211
16
  extensions: []
212
17
  extra_rdoc_files: []
213
18
  files:
19
+ - ".devcontainer/devcontainer.json"
20
+ - ".devcontainer/docker-compose.yml"
214
21
  - ".github/dependabot.yml"
215
22
  - ".github/workflows/tests.yml"
216
23
  - ".gitignore"
@@ -281,7 +88,6 @@ metadata:
281
88
  homepage_uri: https://github.com/gocardless/statesman
282
89
  source_code_uri: https://github.com/gocardless/statesman
283
90
  rubygems_mfa_required: 'true'
284
- post_install_message:
285
91
  rdoc_options: []
286
92
  require_paths:
287
93
  - lib
@@ -289,15 +95,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
289
95
  requirements:
290
96
  - - ">="
291
97
  - !ruby/object:Gem::Version
292
- version: '3.0'
98
+ version: '3.2'
293
99
  required_rubygems_version: !ruby/object:Gem::Requirement
294
100
  requirements:
295
101
  - - ">="
296
102
  - !ruby/object:Gem::Version
297
103
  version: '0'
298
104
  requirements: []
299
- rubygems_version: 3.4.10
300
- signing_key:
105
+ rubygems_version: 3.6.9
301
106
  specification_version: 4
302
107
  summary: A statesman-like state machine library
303
108
  test_files: []