Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

new: name the app's folder in the spec approve step (#1375)

jakalijey97c58ceac120
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9bab2003..2a4615e9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -221,6 +221,9 @@
(#1337 by @jakalijey).
from one JVM start to the next. `List.of`, `Collectors.toList`, and a `toMap` or `groupingBy`
given a `TreeMap` or `LinkedHashMap` supplier are not (#1343 by @jakalijey).
+- `new` ends with a `spec approve` command that names the app's folder, quoted when it needs to
+ be, and with the paths of `spec/SPEC.md` and `spec/cases` in that folder, so the printed command
+ works from where `new` was run (#1358 by @jakalijey).
- PowerShell: a parameter typed `[decimal]`, `[uint64]` or `[ulong]` keeps its function in
PowerShell, with the reasons C# gives for the same types, instead of bridging it as `f64` or
`i64`. `[uint32]`, `[double]` and `[single]` bridge as before (#1341 by @jakalijey).
diff --git a/src/main.rs b/src/main.rs
index 4aa2c3f6..3ae1e395 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2542,7 +2542,10 @@ fn run() -> Result<ExitCode> {
say!(" {file}");
}
say!(
- "Next: write what the app does in spec/SPEC.md and its cases in spec/cases (hello is an example to replace), then approve them with `rust-anything spec approve`."
+ "Next: write what the app does in {} and its cases in {} (hello is an example to replace), then approve them with `rust-anything spec approve {}`.",
+ dir.join("spec").join("SPEC.md").display(),
+ dir.join("spec").join("cases").display(),
+ rust_anything::app::cli_path(&dir)
);
}
}
diff --git a/tests/spec.rs b/tests/spec.rs
index 2083a6c3..d1e1f146 100644
--- a/tests/spec.rs
+++ b/tests/spec.rs
@@ -109,6 +109,17 @@ fn the_cli_starts_an_app_once_and_check_fails_until_done() {
let made = common::cli().arg("new").arg(&app).output().unwrap();
assert!(made.status.success());
assert!(app.join(spec::SPEC).is_file());
+ let stdout = String::from_utf8_lossy(&made.stdout);
+ let approve = format!(
+ "`rust-anything spec approve {}`",
+ rust_anything::app::cli_path(&app)
+ );
+ assert!(stdout.contains(&approve), "{approve} not in {stdout}");
+ let cases = app.join("spec").join("cases");
+ assert!(
+ stdout.contains(&format!("its cases in {} ", cases.display())),
+ "{stdout}"
+ );
let again = common::cli().arg("new").arg(&app).output().unwrap();
assert!(!again.status.success(), "new never writes over files");
@@ -134,6 +145,26 @@ fn the_cli_starts_an_app_once_and_check_fails_until_done() {
assert!(!app.join("rust").exists());
}
+#[test]
+fn new_quotes_a_folder_with_a_space_in_its_next_step() {
+ let root = temp("space");
+ let app = root.join("my tool");
+ let made = common::cli()
+ .arg("new")
+ .arg(&app)
+ .args(["--name", "my-tool"])
+ .output()
+ .unwrap();
+ assert!(made.status.success(), "{made:?}");
+ let stdout = String::from_utf8_lossy(&made.stdout);
+ let quoted = rust_anything::app::cli_path(&app);
+ assert_ne!(quoted, app.display().to_string(), "a space is quoted");
+ assert!(
+ stdout.contains(&format!("`rust-anything spec approve {quoted}`")),
+ "{stdout}"
+ );
+}
+
#[test]
fn a_name_cargo_would_refuse_is_refused_before_any_file_is_written() {
let root = temp("name");