An AI agent built to do Ralph loops - plan mode for planning and ralph mode for implementing.
1use std::process::Command;
2use tempfile::TempDir;
3
4#[test]
5fn test_init_creates_spec_directory() {
6 let temp = TempDir::new().unwrap();
7 let spec_dir = temp.path().join("specs");
8
9 let exe = env!("CARGO_BIN_EXE_rustagent");
10
11 let output = Command::new(exe)
12 .args(["init", "--spec-dir", spec_dir.to_str().unwrap()])
13 .current_dir(temp.path())
14 .output()
15 .unwrap();
16
17 assert!(output.status.success(), "Command failed: {:?}", output);
18 assert!(spec_dir.exists());
19 assert!(spec_dir.is_dir());
20}
21
22#[test]
23fn test_init_creates_config_template() {
24 let temp = TempDir::new().unwrap();
25 let spec_dir = temp.path().join("specs");
26
27 let exe = env!("CARGO_BIN_EXE_rustagent");
28
29 let output = Command::new(exe)
30 .args(["init", "--spec-dir", spec_dir.to_str().unwrap()])
31 .current_dir(temp.path())
32 .output()
33 .unwrap();
34
35 assert!(output.status.success(), "Command failed: {:?}", output);
36
37 let config_path = temp.path().join("rustagent.toml");
38 assert!(config_path.exists(), "Config file was not created");
39}
40
41#[test]
42fn test_init_idempotent() {
43 let temp = TempDir::new().unwrap();
44 let spec_dir = temp.path().join("specs");
45
46 let exe = env!("CARGO_BIN_EXE_rustagent");
47
48 Command::new(exe)
49 .args(["init", "--spec-dir", spec_dir.to_str().unwrap()])
50 .current_dir(temp.path())
51 .output()
52 .unwrap();
53
54 let output = Command::new(exe)
55 .args(["init", "--spec-dir", spec_dir.to_str().unwrap()])
56 .current_dir(temp.path())
57 .output()
58 .unwrap();
59
60 assert!(output.status.success(), "Second init failed: {:?}", output);
61}