Repository navigation
Conversation
The TestUnit template names ActiveAgent::TestCase, which the framework does not define. Every generated test fails while loading, even when the agent has no actions. Use ActiveSupport::TestCase and run plain, namespaced and empty generated tests in fresh Rails hosts to cover the installed result.
Contributor
|
Thanks @yorzi — read through this one and it looks good to me. Tight scope, the root cause is right ( Before I merge: do you want a proper line-by-line review on this, or are you happy for it to go in as-is? And is there anything else you have planned on this branch, or is it done? |
Contributor
Author
|
@TonsOfFun Thanks! I’m comfortable with this being merged as-is if you’re satisfied with the current review. This branch is complete for the generated-test fix; I don’t have further changes planned for it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every test that
rails generate active_agent:agentwrites fails while loading:The TestUnit template inherits from
ActiveAgent::TestCase, which the framework has never defined (the only other mention is a commented-out line in the Railtie). It fails even for an agent generated without actions, whose test body is all comments. The existing generator tests only matched the file's text, so they asserted the broken superclass instead of catching it.What changes
lib/generators/test_unit/templates/functional_test.rb.tt: generated tests inherit fromActiveSupport::TestCase, the class the docs' own test examples already use.test/generators/test_unit/agent_generator_test.rb: the text assertions expect the new superclass.test/generators/active_agent/generated_agent_test.rb(new): generates an agent into a scratch Rails host (framework railties plusactive_agent, no Active Record) and runs the generated test file in a subprocess. Covers a plain agent, a namespaced agent and an agent without actions, and asserts the exact run and assertion counts.Checks
NameErrorabove. With the fix, they pass.bin/test: 4095 runs, 0 failures, 0 errors.bin/rubocopreports no offenses on the changed files.🤖 Generated with Claude Code