Skip to content

Make aasm compiler v6.0 aware#2672

Open
allan-thatch wants to merge 1 commit into
Shopify:mainfrom
thatch-health:aasm-6.0
Open

Make aasm compiler v6.0 aware#2672
allan-thatch wants to merge 1 commit into
Shopify:mainfrom
thatch-health:aasm-6.0

Conversation

@allan-thatch

@allan-thatch allan-thatch commented Jul 14, 2026

Copy link
Copy Markdown

Motivation

Fixes #2671. Also see "Migrating from AASM version 5 to 6".

Implementation

The aasm compiler now (a) withholds plain methods when namespaced and on v6 and (b) adds the namespaced _without_validation! method when on v6.

Tests

I updated the compiler test to accommodate the v6.0 path, but didn't add a backtest for v5.5.2 and lower. Let me know if you'd like to see that; otherwise, I ran a local test by pinning the older version and restoring the original RBI fixture:

diff --git a/Gemfile b/Gemfile
index 43b343c3..aa41b9fd 100644
--- a/Gemfile
+++ b/Gemfile
@@ -52,7 +52,7 @@ group :development, :test do
   gem "sidekiq"
   gem "nokogiri"
   gem "config"
-  gem "aasm"
+  gem "aasm", "5.5.2"
   gem "bcrypt"
   gem "xpath"
   gem "kredis"
diff --git a/spec/tapioca/dsl/compilers/aasm_spec.rb b/spec/tapioca/dsl/compilers/aasm_spec.rb
index d5e0ac64..11f019b4 100644
--- a/spec/tapioca/dsl/compilers/aasm_spec.rb
+++ b/spec/tapioca/dsl/compilers/aasm_spec.rb
@@ -358,9 +358,18 @@ module Tapioca
                   sig { returns(T::Boolean) }
                   def foo_sleeping?; end
 
+                  sig { returns(T::Boolean) }
+                  def may_run?; end
+
                   sig { returns(T::Boolean) }
                   def may_run_foo?; end
 
+                  sig { params(opts: T.untyped, block: T.nilable(T.proc.void)).returns(T.untyped) }
+                  def run(*opts, &block); end
+
+                  sig { params(opts: T.untyped, block: T.nilable(T.proc.void)).returns(T.untyped) }
+                  def run!(*opts, &block); end
+
                   sig { params(opts: T.untyped, block: T.nilable(T.proc.void)).returns(T.untyped) }
                   def run_foo(*opts, &block); end
 
@@ -368,7 +377,7 @@ module Tapioca
                   def run_foo!(*opts, &block); end
 
                   sig { params(opts: T.untyped, block: T.nilable(T.proc.void)).returns(T.untyped) }
-                  def run_foo_without_validation!(*opts, &block); end
+                  def run_without_validation!(*opts, &block); end
 
                   class << self
                     sig { params(args: T.untyped, block: T.nilable(T.proc.bind(PrivateAASMMachine).void)).returns(PrivateAASMMachine) }
$ bin/test spec/tapioca/dsl/compilers/aasm_spec.rb
Started with run options --seed 14626

Tapioca::Dsl::Compilers::AASMSpec::Tapioca::Dsl::Compilers::AASM::initialize
  it gathers no constants if there are no classes that include AASM PASS (0.16s)
  it gathers only classes that include AASM                       PASS (0.14s)

Tapioca::Dsl::Compilers::AASMSpec::Tapioca::Dsl::Compilers::AASM::decorate
  it generates correct RBI file with custom and default aasm names PASS (0.44s)
  it generates empty RBI when AASM is included but no AASM call has been made PASS (0.42s)
  it generates correct RBI file with namespace                    PASS (0.17s)
  it generates correct RBI file                                   PASS (0.18s)

Finished in 1.54459s
6 tests, 19 assertions, 0 failures, 0 errors, 0 skips

@allan-thatch allan-thatch requested a review from a team as a code owner July 14, 2026 23:20
@allan-thatch

Copy link
Copy Markdown
Author

I have signed the CLA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aasm 6.0 compiler emits non-existent event methods for namespaced state machines

1 participant