From ee23d589516ddecfe2b67d74e919871884db2c24 Mon Sep 17 00:00:00 2001 From: Bruno Pinto Date: Wed, 14 Jan 2015 22:16:14 -0200 Subject: [PATCH] expect --to-contain tests --- .../spec/expect.to_contain.spec.fish | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 plugins/fish-spec/spec/expect.to_contain.spec.fish diff --git a/plugins/fish-spec/spec/expect.to_contain.spec.fish b/plugins/fish-spec/spec/expect.to_contain.spec.fish new file mode 100644 index 0000000..7907178 --- /dev/null +++ b/plugins/fish-spec/spec/expect.to_contain.spec.fish @@ -0,0 +1,65 @@ +import plugins/fish-spec + +function describe_to_contain -d 'expect --to-contain' + function before_each + set -e result + end + + function it_returns_0_when_arrays_are_the_same + set -l array 1 2 + + echo (expect $array --to-contain $array; set result $status) >/dev/null + expect $result --to-equal 0 + end + + function it_returns_1_when_arrays_are_different + set -l array 1 2 + + echo (expect $array --to-contain 8 9; set result $status) >/dev/null + expect $result --to-equal 1 + end + + function it_returns_0_when_arrays_have_the_same_elements_but_in_different_order + set -l array 1 2 + + echo (expect $array --to-contain 2 1; set result $status) >/dev/null + expect $result --to-equal 0 + end + + function it_returns_0_when_expected_array_contains_the_element + set -l array 1 2 + + echo (expect $array --to-contain 1; set result $status) >/dev/null + expect $result --to-equal 0 + end + + function it_returns_1_when_expected_array_does_not_contain_the_element + set -l array 1 2 + + echo (expect $array --to-contain 9; set result $status) >/dev/null + expect $result --to-equal 1 + end + + function it_returns_0_when_expected_array_contains_all_elements + set -l array 1 2 3 + + echo (expect $array --to-contain 1 2; set result $status) >/dev/null + expect $result --to-equal 0 + end + + function it_returns_1_when_expected_array_does_not_contain_all_elements + set -l array 1 2 3 + + echo (expect $array --to-contain 1 2 9; set result $status) >/dev/null + expect $result --to-equal 1 + end + + function it_returns_1_when_expected_array_contains_less_elements + set -l array 1 2 + + echo (expect $array --to-contain 1 2 9; set result $status) >/dev/null + expect $result --to-equal 1 + end +end + +spec.run $argv