From 81d796472a0c99addb2360ea469272e578f44d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Tue, 30 Jul 2019 11:53:31 -0500 Subject: [PATCH] Improved code readability. --- src/plugins/str.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/plugins/str.rs b/src/plugins/str.rs index 704901a258..f5dec64ca8 100644 --- a/src/plugins/str.rs +++ b/src/plugins/str.rs @@ -23,7 +23,7 @@ impl Str { } } - fn fields(&self) -> u8 { + fn actions_desired(&self) -> u8 { [self.downcase, self.upcase, self.int].iter().fold( 0, |acc, &field| { @@ -41,11 +41,11 @@ impl Str { } fn at_most_one(&self) -> bool { - self.fields() == 1 + self.actions_desired() == 1 } fn none(&self) -> bool { - self.fields() == 0 + self.actions_desired() == 0 } fn log_error(&mut self, message: &str) { @@ -301,7 +301,7 @@ mod tests { } #[test] - fn str_accepts_only_one_flag() { + fn str_accepts_only_one_action() { let mut strutils = Str::new(); assert!(strutils @@ -332,15 +332,6 @@ mod tests { assert_eq!(Some("package.description".to_string()), strutils.field); } - #[test] - fn str_reports_error_if_no_field_given_for_object() { - let mut strutils = Str::new(); - let subject = sample_record("name", "jotandrehuda"); - - assert!(strutils.begin_filter(CallStub::new().create()).is_ok()); - assert!(strutils.filter(subject).is_err()); - } - #[test] fn str_downcases() { let mut strutils = Str::new(); @@ -363,7 +354,7 @@ mod tests { } #[test] - fn str_applies_upcase() { + fn str_plugin_applies_upcase() { let mut strutils = Str::new(); assert!(strutils @@ -391,7 +382,7 @@ mod tests { } #[test] - fn str_applies_downcase() { + fn str_plugin_applies_downcase() { let mut strutils = Str::new(); assert!(strutils @@ -419,7 +410,7 @@ mod tests { } #[test] - fn str_applies_to_int() { + fn str_plugin_applies_to_int() { let mut strutils = Str::new(); assert!(strutils