-
Notifications
You must be signed in to change notification settings - Fork 3
Fix Rails main integration tests #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,13 @@ | |
| require "test_helper" | ||
|
|
||
| class LoggingIntegrationTest < ActionDispatch::IntegrationTest | ||
| # Rails assigns ActiveSupport::LogSubscriber.logger once during boot, so log | ||
| # subscribers (Lograge, Active Record, Action Controller) write to that | ||
| # reference rather than looking up Rails.logger on each event. | ||
| def test_log_subscribers_use_the_logstruct_logger | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
file="rails_test_app/templates/test/integration/logging_integration_test.rb"
printf '%s\n' "== target file =="
cat -n "$file"
printf '%s\n' "== Sorbet setup and method signatures in related integration tests =="
rg -n --glob '*.rb' 'T::Sig|sig \{|def test_log_subscribers_use_the_logstruct_logger|def test_' rails_test_app/templates/test rails_test_app/test test 2>/dev/null | head -n 250
printf '%s\n' "== references to the target template and generated test annotations =="
rg -n 'logging_integration_test|typed:|test_log_subscribers_use_the_logstruct_logger' . --glob '*.rb' --glob '*.erb' --glob '*.haml' --glob '*.slim' --glob '*.yml' 2>/dev/null | head -n 250Repository: DocSpring/logstruct Length of output: 36441 🏁 Script executed: #!/bin/bash
set -eu
file="rails_test_app/templates/test/integration/logging_integration_test.rb"
printf '%s\n' "== target file =="
cat -n "$file"
printf '%s\n' "== Sorbet setup and related test methods =="
rg -n --glob '*.rb' 'T::Sig|sig \{|def test_log_subscribers_use_the_logstruct_logger|def test_' rails_test_app/templates/test rails_test_app/test test 2>/dev/null | head -n 250
printf '%s\n' "== target references and typed annotations =="
rg -n 'logging_integration_test|typed:|test_log_subscribers_use_the_logstruct_logger' . --glob '*.rb' --glob '*.erb' --glob '*.haml' --glob '*.slim' --glob '*.yml' 2>/dev/null | head -n 250Repository: DocSpring/logstruct Length of output: 36390 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' "== Sorbet and RuboCop rules =="
sed -n '70,125p' .rubocop.yml
printf '%s\n' "== Rails test helper setup =="
cat -n rails_test_app/templates/test/test_helper.rb | sed -n '1,180p'
printf '%s\n' "== Integration template headers and class-level Sorbet setup =="
for file in rails_test_app/templates/test/integration/*.rb; do
printf '\n-- %s --\n' "$file"
sed -n '1,35p' "$file"
done
printf '%s\n' "== Generation path for test templates =="
rg -n 'templates/test|test/integration|logging_integration_test|FileUtils|ERB|template' rails_test_app/create_app.rb rails_test_app scripts lib 2>/dev/null | head -n 250Repository: DocSpring/logstruct Length of output: 32304 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' "== Sorbet and RuboCop rules =="
sed -n '70,125p' .rubocop.yml
printf '%s\n' "== Rails test helper setup =="
cat -n rails_test_app/templates/test/test_helper.rb | sed -n '1,180p'
printf '%s\n' "== Integration template headers and Sorbet setup =="
for file in rails_test_app/templates/test/integration/*.rb; do
printf '\n-- %s --\n' "$file"
sed -n '1,35p' "$file"
done
printf '%s\n' "== Generation path for test templates =="
rg -n 'templates/test|test/integration|logging_integration_test|FileUtils|ERB|template' rails_test_app/create_app.rb rails_test_app scripts lib 2>/dev/null | head -n 250Repository: DocSpring/logstruct Length of output: 32292 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' "== Existing signature patterns in test classes =="
cat -n test/schemas/schema_validation_test.rb | sed -n '1,55p'
cat -n test/log_struct/integrations/active_job_test.rb | sed -n '1,45p'
rg -n -U 'class [A-Za-z0-9_:]+.*\n(?:.*\n){0,12}\s+extend T::Sig|\s+extend T::Sig' test rails_test_app/templates --glob '*.rb' | head -n 160
printf '%s\n' "== Signature-related configuration and template exclusions =="
rg -n 'Sorbet/|typed: true|T::Sig|sig \{' .rubocop.yml sorbet test rails_test_app/templates --glob '*.rb' --glob '*.rbi' --glob '*.yml' | head -n 250
printf '%s\n' "== Static check of the target class and method =="
python3 - <<'PY'
from pathlib import Path
import re
p = Path("rails_test_app/templates/test/integration/logging_integration_test.rb")
text = p.read_text()
class_match = re.search(r"^class\s+LoggingIntegrationTest\b(?P<body>.*)^end\s*$", text, re.M | re.S)
body = class_match.group("body") if class_match else ""
method = re.search(
r"(?m)^(?P<indent>\s*)def\s+test_log_subscribers_use_the_logstruct_logger\b",
text,
)
print("typed_sigil:", text.splitlines()[0] if text.splitlines() else None)
print("has_class_extend_T_Sig:", bool(re.search(r"^\s*extend\s+T::Sig\s*$", body, re.M)))
print("method_has_immediately_preceding_sig:", bool(re.search(
r"(?m)^\s*sig\s*\{\s*void\s*\}\s*\n\s*def\s+test_log_subscribers_use_the_logstruct_logger\b",
text,
)))
print("method_present:", bool(method))
PYRepository: DocSpring/logstruct Length of output: 29103 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' "== Existing signature patterns in test classes =="
cat -n test/schemas/schema_validation_test.rb | sed -n '1,55p'
cat -n test/log_struct/integrations/active_job_test.rb | sed -n '1,45p'
rg -n -U 'class [A-Za-z0-9_:]+.*\n(?:.*\n){0,12}\s+extend T::Sig|\s+extend T::Sig' test rails_test_app/templates --glob '*.rb' | head -n 160
printf '%s\n' "== Signature-related configuration and template exclusions =="
rg -n 'Sorbet/|typed: true|T::Sig|sig \{' .rubocop.yml sorbet test rails_test_app/templates --glob '*.rb' --glob '*.rbi' --glob '*.yml' | head -n 250
printf '%s\n' "== Static check of the target class and method =="
python3 - <<'PY'
from pathlib import Path
import re
p = Path("rails_test_app/templates/test/integration/logging_integration_test.rb")
text = p.read_text()
class_match = re.search(r"^class\s+LoggingIntegrationTest\b(?P<body>.*)^end\s*$", text, re.M | re.S)
body = class_match.group("body") if class_match else ""
print("typed_sigil:", text.splitlines()[0] if text.splitlines() else None)
print("has_class_extend_T_Sig:", bool(re.search(r"^\s*extend\s+T::Sig\s*$", body, re.M)))
print("method_has_immediately_preceding_sig:", bool(re.search(
r"(?m)^\s*sig\s*\{\s*void\s*\}\s*\n\s*def\s+test_log_subscribers_use_the_logstruct_logger\b",
text,
)))
print("method_present:", bool(re.search(
r"(?m)^\s*def\s+test_log_subscribers_use_the_logstruct_logger\b",
text,
)))
PYRepository: DocSpring/logstruct Length of output: 25289 Add a Sorbet signature to the new test method. Add 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| assert_kind_of LogStruct::SemanticLogger::Logger, ActiveSupport::LogSubscriber.logger | ||
| end | ||
|
|
||
| # Basic test to ensure the Rails app is working | ||
| def test_healthcheck_works | ||
| get "/health" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,15 @@ | |
| require "open3" | ||
| require "timeout" | ||
|
|
||
| unless SimpleCov.running | ||
| # SimpleCov >= 1.0 replaced the `running` accessor with `active_session?` | ||
| simplecov_started = | ||
| if SimpleCov.respond_to?(:active_session?) | ||
| SimpleCov.active_session? | ||
| else | ||
| SimpleCov.running | ||
| end | ||
|
Comment on lines
+12
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- test_helper.rb ---'
cat -n rails_test_app/templates/test/test_helper.rb
printf '%s\n' '--- create_app.rb relevant section ---'
sed -n '330,380p' rails_test_app/create_app.rb
printf '%s\n' '--- Ruby file headers and SimpleCov references ---'
rg -n -C 2 'SimpleCov|module LogStruct|class |# typed:' rails_test_app/templates/test/test_helper.rb rails_test_app/create_app.rb
printf '%s\n' '--- repository guidance ---'
for f in AGENTS.md .cursor/rules/sorbet.mdc; do
if [ -f "$f" ]; then
printf '\n--- %s ---\n' "$f"
cat "$f"
fi
doneRepository: DocSpring/logstruct Length of output: 26503 Qualify all Apply this in 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| unless simplecov_started | ||
| SimpleCov.formatters = [ | ||
| SimpleCov::Formatter::HTMLFormatter, | ||
| SimpleCov::Formatter::JSONFormatter | ||
|
|
@@ -19,7 +27,12 @@ | |
| gem_path = File.expand_path("../../../../", __FILE__) | ||
| SimpleCov.root(gem_path) | ||
|
|
||
| add_filter "rails_test_app" | ||
| # SimpleCov >= 1.0 deprecated `add_filter` in favor of `skip` | ||
| if SimpleCov.respond_to?(:skip) | ||
| SimpleCov.skip "rails_test_app" | ||
| else | ||
| SimpleCov.add_filter "rails_test_app" | ||
| end | ||
|
|
||
| coverage_dir "coverage_rails" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: DocSpring/logstruct
Length of output: 27696
🏁 Script executed:
Repository: DocSpring/logstruct
Length of output: 911
Use top-level
::ActiveSupportprefixes at both sites.Update
setup.rbandlogging_integration_test.rbto use::ActiveSupport::LogSubscriber.logger. This avoids nested constant lookup and follows the repository convention.📍 Affects 2 files
lib/log_struct/semantic_logger/setup.rb#L228-L228(this comment)rails_test_app/templates/test/integration/logging_integration_test.rb#L11-L11🤖 Prompt for AI Agents
Source: Coding guidelines