reef 0.0.50

a package to execute and log system commands
Documentation
#[cfg(test)]
use reef::{Command, Status};
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use tempdir::TempDir;

#[test]
fn exec_test() {
    let git_version = Command::new("git --version").exec();
    assert_eq!(git_version.status, Status::Ok);
    assert!(git_version.stdout.contains("git version"));
    let dir = PathBuf::from(git_version.dir);
    assert!(dir.exists(), "dir");
}

#[test]
fn exec_rake_test() -> std::io::Result<()> {
    let tmp_dir = TempDir::new("rake_test")?;
    let rakefile_content = include_str!("rakefile.rb");
    match reef::Env::which("rake") {
        Ok(_rake_path) => {
            let rakefile_path = tmp_dir.path().join("rakefile.rb");
            {
                let mut rakefile = File::create(&rakefile_path)?;
                rakefile.write_all(rakefile_content.as_bytes())?;
            }

            assert!(&rakefile_path.exists());

            let cmd = "rake default".to_string(); // format!("ruby {} default", rake_path.display());
            let rake_default = Command::new(&cmd).exec_in(&tmp_dir.path());
            assert_eq!(rake_default.status, Status::Ok, "{:?}", rake_default);
            assert!(rake_default.stdout.contains("default"));
        }
        Err(_) => {}
    };
    tmp_dir.close()?;
    Ok(())
}

#[test]
fn unknown_command() {
    //-> std::io::Result<()> {
    let c = Command::new("unknown").exec();
    assert_eq!(Status::Error, c.status);

    /*{
        Ok(_unknown) => {
            assert!(
                false,
                "did not expect the command 'unknown' to be recognized"
            );
        }
        Err(_e) => {}
    };
    Ok(())*/
}