Skip to content

feat: support insert_into_file erroring if the file is not changed, and add insert_into_file #908

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

Merged
merged 2 commits into from
Jul 21, 2025

Conversation

G-Rath
Copy link
Contributor

@G-Rath G-Rath commented Jul 21, 2025

🌈


Following on from #877, this adds a bang version of insert_into_file and its alias

@@ -2,6 +2,38 @@

class Thor
module Actions
WARNINGS = {unchanged_no_flag: "File unchanged! Either the supplied flag value not found or the content has already been inserted!"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: moving this is good anyway because it was the subject of the method comment intended for insert_into_file 😅

@@ -20,6 +20,10 @@ def invoke!(*args, &block)
capture(:stdout) { invoker.insert_into_file(*args, &block) }
end

def invoke_with_a_bang!(*args, &block)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this seemed like the most straightforward, if a little whimsical, way of handling the tests

Happy to go with an alternative structure though if desired

@rafaelfranca rafaelfranca merged commit c049fb6 into rails:main Jul 21, 2025
9 checks passed
@G-Rath G-Rath deleted the new-inject-into-file-helper branch July 21, 2025 20:16
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.

2 participants