Skip to content

Commit

Permalink
feat(hint): Add test for hint
Browse files Browse the repository at this point in the history
  • Loading branch information
marisa committed Nov 11, 2019
1 parent 795b6e3 commit ce9fa6e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/fixture/failure/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "compFailure"
path = "compFailure.rs"
mode = "compile"
hint = """"""
hint = ""

[[exercises]]
name = "testFailure"
path = "testFailure.rs"
mode = "test"
hint = """"""
hint = "Hello!"
11 changes: 11 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit ce9fa6e

Please sign in to comment.