From 58daae022b3111149c311a36fb000c4050b746b5 Mon Sep 17 00:00:00 2001
From: Bruno Pinto <brunoferreirapinto@gmail.com>
Date: Sat, 19 Dec 2015 13:29:45 +0000
Subject: [PATCH] Improve assertion error messages

---
 pkg/fish-spec/functions/assert.error_message.fish | 12 ++++++------
 pkg/fish-spec/spec/assert_error_message_spec.fish | 10 +++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/pkg/fish-spec/functions/assert.error_message.fish b/pkg/fish-spec/functions/assert.error_message.fish
index 3b7f349..cac1716 100644
--- a/pkg/fish-spec/functions/assert.error_message.fish
+++ b/pkg/fish-spec/functions/assert.error_message.fish
@@ -6,26 +6,26 @@ function assert.error_message
       switch $number_of_arguments
         case 3
           set operator (assert.expand_operator $argv[2])
-          set expected $argv[3]
-          echo "Expected $expected to not be $operator"
+          set actual $argv[3]
+          echo "Expected result to not be $operator but it was $actual"
         case 4
           set expected $argv[2]
           set operator "not" (assert.expand_operator $argv[3])
           set actual   $argv[4]
-          echo "Expected $expected to $operator $actual"
+          echo "Expected result to $operator $expected but it was $actual"
         case \*
           return 1
         end
     case \-\*
       test $number_of_arguments != 2; and return 1
       set operator (assert.expand_operator $argv[1])
-      set expected $argv[2]
-      echo "Expected $expected to be $operator"
+      set actual $argv[2]
+      echo "Expected result to be $operator but it was $actual"
     case \*
       test $number_of_arguments != 3; and return 1
       set expected $argv[1]
       set operator (assert.expand_operator $argv[2])
       set actual   $argv[3]
-      echo "Expected $expected to $operator $actual"
+      echo "Expected result to $operator $expected but it was $actual"
   end
 end
diff --git a/pkg/fish-spec/spec/assert_error_message_spec.fish b/pkg/fish-spec/spec/assert_error_message_spec.fish
index 9914752..bfc7ad2 100644
--- a/pkg/fish-spec/spec/assert_error_message_spec.fish
+++ b/pkg/fish-spec/spec/assert_error_message_spec.fish
@@ -17,12 +17,12 @@ function describe_assert_error_message
   end
 
   function it_supports_unary_operators
-    assert -z "string"
+    assert -z "abc"
 
     # Reset test status
     set -e __current_spec_status
 
-    assert 'Expected string to be empty' = "$__current_spec_output"
+    assert 'Expected result to be empty but it was abc' = "$__current_spec_output"
   end
 
   function it_supports_binary_operators
@@ -31,7 +31,7 @@ function describe_assert_error_message
     # Reset test status
     set -e __current_spec_status
 
-    assert 'Expected 1 to equals 2' = "$__current_spec_output"
+    assert 'Expected result to equals 1 but it was 2' = "$__current_spec_output"
   end
 
   function it_supports_inversion_on_unary_operators
@@ -40,7 +40,7 @@ function describe_assert_error_message
     # Reset test status
     set -e __current_spec_status
 
-    assert 'Expected  to not be empty' = "$__current_spec_output"
+    assert 'Expected result to not be empty but it was ' = "$__current_spec_output"
   end
 
   function it_supports_inversion_on_binary_operators
@@ -49,6 +49,6 @@ function describe_assert_error_message
     # Reset test status
     set -e __current_spec_status
 
-    assert 'Expected 1 to not equals 1' = "$__current_spec_output"
+    assert 'Expected result to not equals 1 but it was 1' = "$__current_spec_output"
   end
 end
-- 
GitLab