I come from Python where you have monkeypatch in pytest, so I refer to the operation I want to do as monkeypatching, however, I've been told that the actual operation is called mocking more generally.
Anyway, my application uses the ncurses crate, and I need to test some code that calls it. How would I monkeypatch (mock) the calls to crate's functions, methods, and other attributes properly?
For example,
fn get_page(&self, commands: &[String]) -> Vec<String> {
match commands
.chunks(ncurses::LINES() as usize - 3)
.nth(self.page as usize - 1)
{
Some(cmds) => cmds.to_vec(),
None => Vec::new(),
}
}
How would I patch the ncurses::LINES() call?