From ce9fa6ebbfdc3e7585d488d9409797285708316f Mon Sep 17 00:00:00 2001 From: marisa Date: Mon, 11 Nov 2019 17:19:50 +0100 Subject: [PATCH] feat(hint): Add test for hint --- src/main.rs | 15 ++++++++------- tests/fixture/failure/info.toml | 4 ++-- tests/integration_tests.rs | 11 +++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 69a7b22b..875f7675 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,9 +65,7 @@ fn main() { std::process::exit(1); }); - let matching_exercise = |e: &&Exercise| { - name == e.name - }; + let matching_exercise = |e: &&Exercise| name == e.name; let exercise = exercises.iter().find(matching_exercise).unwrap_or_else(|| { println!("No exercise found for your given name!"); @@ -83,10 +81,13 @@ fn main() { std::process::exit(1); }); - let exercise = exercises.iter().find(|e| name == e.name).unwrap_or_else(|| { - println!("No exercise found for your given name!"); - std::process::exit(1) - }); + let exercise = exercises + .iter() + .find(|e| name == e.name) + .unwrap_or_else(|| { + println!("No exercise found for your given name!"); + std::process::exit(1) + }); println!("{}", exercise.hint); } diff --git a/tests/fixture/failure/info.toml b/tests/fixture/failure/info.toml index 20d570a1..e5949f9b 100644 --- a/tests/fixture/failure/info.toml +++ b/tests/fixture/failure/info.toml @@ -2,10 +2,10 @@ name = "compFailure" path = "compFailure.rs" mode = "compile" -hint = """""" +hint = "" [[exercises]] name = "testFailure" path = "testFailure.rs" mode = "test" -hint = """""" +hint = "Hello!" diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 652ba605..24268ec5 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -105,3 +105,14 @@ fn run_single_test_no_exercise() { .assert() .code(1); } + +#[test] +fn get_hint_for_single_test() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["h", "testFailure"]) + .current_dir("tests/fixture/failure") + .assert() + .code(0) + .stdout("Hello!\n"); +}