From 9a7292ac9d7f4b3a9ad3efb4af6993d6a58ca352 Mon Sep 17 00:00:00 2001 From: Bruno Pinto Date: Sat, 17 Jan 2015 13:29:09 -0200 Subject: [PATCH] fail tests when using an invalid comparison --- plugins/fish-spec/expect.fish | 2 ++ plugins/fish-spec/spec/expect.spec.fish | 14 ++++++++++++++ spec/oh-my-fish.spec.fish | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 plugins/fish-spec/spec/expect.spec.fish diff --git a/plugins/fish-spec/expect.fish b/plugins/fish-spec/expect.fish index 8c892fd..9e43843 100644 --- a/plugins/fish-spec/expect.fish +++ b/plugins/fish-spec/expect.fish @@ -78,6 +78,8 @@ function expect test "$expected" = "$actual" case --to-not-equal test "$expected" != "$actual" + case \* + test true = false end set result $status diff --git a/plugins/fish-spec/spec/expect.spec.fish b/plugins/fish-spec/spec/expect.spec.fish new file mode 100644 index 0000000..8fa0728 --- /dev/null +++ b/plugins/fish-spec/spec/expect.spec.fish @@ -0,0 +1,14 @@ +import plugins/fish-spec + +function describe_expect + function before_each + set -e result + end + + function it_is_false_when_comparison_does_not_exist + echo (expect true --invalid-comparison; set result $status) >/dev/null + expect $result --to-equal 1 + end +end + +spec.run $argv diff --git a/spec/oh-my-fish.spec.fish b/spec/oh-my-fish.spec.fish index 8ce3514..a5d5658 100755 --- a/spec/oh-my-fish.spec.fish +++ b/spec/oh-my-fish.spec.fish @@ -16,13 +16,13 @@ function describe_oh_my_fish function it_has_a_default_custom_directory set -e fish_custom load_oh_my_fish - expect $fish_custom --to-eq "$HOME/.oh-my-fish/custom" + expect $fish_custom --to-equal "$HOME/.oh-my-fish/custom" end function it_allows_the_custom_folder_location_to_be_customized set -g fish_custom /tmp load_oh_my_fish - expect $fish_custom --to-eq '/tmp' + expect $fish_custom --to-equal '/tmp' end function it_loads_all_custom_files @@ -30,7 +30,7 @@ function describe_oh_my_fish echo 'set -gx TEST_LOAD_CUSTOM_FILE file_loaded' > $fish_custom/test.load load_oh_my_fish - expect $TEST_LOAD_CUSTOM_FILE --to-eq 'file_loaded' + expect $TEST_LOAD_CUSTOM_FILE --to-equal 'file_loaded' end function it_loads_all_oh_my_fish_functions