Repository: myelin-ai/mockiato (rust)

Issue:
Change wording if no calls were expected
Replace `The following calls were expected:` with `No calls were expected`

Pull request:
Change wording if no calls were expected
Resolves #65

Patch:
diff --git a/mockiato/src/internal/method.rs b/mockiato/src/internal/method.rs
index 6eb5817..2e6c9b6 100644
--- a/mockiato/src/internal/method.rs
+++ b/mockiato/src/internal/method.rs
@@ -43,7 +43,8 @@ where
     }
 
     pub fn call_unwrap<'a>(&'a self, arguments: <A as ArgumentsMatcher<'a>>::Arguments) -> R {
-        self.call(arguments).unwrap_or_else(|err| panic!("{}", err))
+        self.call(arguments)
+            .unwrap_or_else(|err| panic!("\n\n{}\n", err))
     }
 
     pub fn verify_unwrap(&self) {
@@ -101,22 +102,22 @@ where
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self {
-            CallError::NoMatching(arguments, method) => write!(
-                f,
-                r#"
-The call {:?} was not expected.
-The following calls were expected:
-{}
-"#,
-                arguments,
-                DisplayCalls(&method.calls.iter().collect::<Vec<_>>())
-            ),
-            CallError::MoreThanOneMatching(arguments, calls) => write!(
+            CallError::NoMatching(arguments, method) => {
+                writeln!(f, "The call {:?} was not expected.", arguments,)?;
+
+                if method.calls.is_empty() {
+                    writeln!(f, "No calls to {} were expected.", method.name)
+                } else {
+                    writeln!(
+                        f,
+                        "The following calls were expected:\n{}",
+                        DisplayCalls(&method.calls.iter().collect::<Vec<_>>())
+                    )
+                }
+            }
+            CallError::MoreThanOneMatching(arguments, calls) => writeln!(
                 f,
-                r#"
-The call {:?} matches more than one expected call:
-{}
-"#,
+                "\nThe call {:?} matches more than one expected call:\n{}",
                 arguments,
                 DisplayCalls(&calls)
             ),


Test patch:
diff --git a/mockiato/tests/panic_with_no_expected_calls.rs b/mockiato/tests/panic_with_no_expected_calls.rs
new file mode 100644
index 0000000..7e41823
--- /dev/null
+++ b/mockiato/tests/panic_with_no_expected_calls.rs
@@ -0,0 +1,16 @@
+use mockiato::mockable;
+
+#[mockable]
+trait Greeter {
+    fn greet(&self, name: &str) -> String;
+}
+
+#[test]
+#[should_panic(
+    expected = "The call (\"John\",) was not expected.\nNo calls to GreeterMock::greet were expected."
+)]
+fn panics_with_no_expected_calls() {
+    let greeter = GreeterMock::new();
+
+    greeter.greet("John");
+}