From 5e2f42c3b45b701f3aa321e71d88dc5736b393c7 Mon Sep 17 00:00:00 2001 From: Bruno Pinto Date: Sat, 17 Jan 2015 13:10:32 -0200 Subject: [PATCH] Closes #322: rename to-(not-)contain to to-(not-)contain-all --- plugins/bak/spec/bak.spec.fish | 8 +-- plugins/fish-spec/expect.fish | 16 ++--- ...c.fish => expect.to_contain_all.spec.fish} | 18 ++--- .../spec/expect.to_not_contain.spec.fish | 65 ------------------- .../spec/expect.to_not_contain_all.spec.fish | 49 ++++++++++++++ plugins/fish-spec/spec/list.erase.spec.fish | 24 +++---- spec/oh-my-fish.spec.fish | 8 +-- 7 files changed, 86 insertions(+), 102 deletions(-) rename plugins/fish-spec/spec/{expect.to_contain.spec.fish => expect.to_contain_all.spec.fish} (63%) delete mode 100644 plugins/fish-spec/spec/expect.to_not_contain.spec.fish create mode 100644 plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish diff --git a/plugins/bak/spec/bak.spec.fish b/plugins/bak/spec/bak.spec.fish index 7616fab..3ef34b2 100644 --- a/plugins/bak/spec/bak.spec.fish +++ b/plugins/bak/spec/bak.spec.fish @@ -65,7 +65,7 @@ function describe_bak_plugin touch a cpbak a - expect (ls -p) --to-contain (echo 'a'\n(__bak_name a)) + expect (ls -p) --to-contain-all (echo 'a'\n(__bak_name a)) end function it_copies_multiple_files @@ -77,7 +77,7 @@ function describe_bak_plugin set files_bak $files_bak (__bak_name $f) end - expect (ls) --to-contain $files $file_bak + expect (ls) --to-contain-all $files $file_bak end function it_undo_copies_of_a_single_file @@ -86,7 +86,7 @@ function describe_bak_plugin rm a uncpbak (ls) - expect (ls) --to-contain (echo 'a'\n(__bak_name a)) + expect (ls) --to-contain-all (echo 'a'\n(__bak_name a)) end function it_undo_copies_of_multiple_files @@ -104,7 +104,7 @@ function describe_bak_plugin rmdir a uncpbak (ls -p) - expect (ls -p) --to-contain (echo 'a/'\n(__bak_name a)'/') + expect (ls -p) --to-contain-all (echo 'a/'\n(__bak_name a)'/') end end diff --git a/plugins/fish-spec/expect.fish b/plugins/fish-spec/expect.fish index 9e43843..ea3d79d 100644 --- a/plugins/fish-spec/expect.fish +++ b/plugins/fish-spec/expect.fish @@ -7,13 +7,13 @@ # OPTIONS # ... # -# --to-equal value equals value -# --to-not-equal value does not equals value +# --to-equal value equals value +# --to-not-equal value does not equals value # -# --to-contain values exist in list -# --to-not-contain values does not exist in list -# --to-be-true exit status should be truthy -# --to-be-false exit status should be falsy +# --to-contain-all all values exist in list +# --to-not-contain-all all values does not exist in list +# --to-be-true exit status should be truthy +# --to-be-false exit status should be falsy # ... # # EXAMPLE @@ -60,14 +60,14 @@ function expect case --to-be-true eval "$expected" test $status -eq 0 - case --to-contain + case --to-contain-all set result 0 for item in $actual contains -- "$item" $expected or set result $status end test $result -eq 0 - case --to-not-contain + case --to-not-contain-all set result 0 for item in $actual contains -- "$item" $expected diff --git a/plugins/fish-spec/spec/expect.to_contain.spec.fish b/plugins/fish-spec/spec/expect.to_contain_all.spec.fish similarity index 63% rename from plugins/fish-spec/spec/expect.to_contain.spec.fish rename to plugins/fish-spec/spec/expect.to_contain_all.spec.fish index e81b078..7ff7bd7 100644 --- a/plugins/fish-spec/spec/expect.to_contain.spec.fish +++ b/plugins/fish-spec/spec/expect.to_contain_all.spec.fish @@ -1,6 +1,6 @@ import plugins/fish-spec -function describe_expect_to_contain +function describe_expect_to_contain_all function before_each set -e result end @@ -8,56 +8,56 @@ function describe_expect_to_contain function it_returns_0_when_lists_are_the_same set -l array 1 2 - echo (expect $array --to-contain $array; set result $status) >/dev/null + echo (expect $array --to-contain-all $array; set result $status) >/dev/null expect $result --to-equal 0 end function it_returns_1_when_lists_are_different set -l array 1 2 - echo (expect $array --to-contain 8 9; set result $status) >/dev/null + echo (expect $array --to-contain-all 8 9; set result $status) >/dev/null expect $result --to-equal 1 end function it_returns_0_when_lists_have_the_same_item_but_in_different_order set -l array 1 2 - echo (expect $array --to-contain 2 1; set result $status) >/dev/null + echo (expect $array --to-contain-all 2 1; set result $status) >/dev/null expect $result --to-equal 0 end function it_returns_0_when_expected_list_contains_the_item set -l array 1 2 - echo (expect $array --to-contain 1; set result $status) >/dev/null + echo (expect $array --to-contain-all 1; set result $status) >/dev/null expect $result --to-equal 0 end function it_returns_1_when_expected_list_does_not_contain_the_item set -l array 1 2 - echo (expect $array --to-contain 9; set result $status) >/dev/null + echo (expect $array --to-contain-all 9; set result $status) >/dev/null expect $result --to-equal 1 end function it_returns_0_when_expected_list_contains_all_items set -l array 1 2 3 - echo (expect $array --to-contain 1 2; set result $status) >/dev/null + echo (expect $array --to-contain-all 1 2; set result $status) >/dev/null expect $result --to-equal 0 end function it_returns_1_when_expected_list_does_not_contain_all_items set -l array 1 2 3 - echo (expect $array --to-contain 1 2 9; set result $status) >/dev/null + echo (expect $array --to-contain-all 1 2 9; set result $status) >/dev/null expect $result --to-equal 1 end function it_returns_1_when_expected_list_contains_less_items set -l array 1 2 - echo (expect $array --to-contain 1 2 9; set result $status) >/dev/null + echo (expect $array --to-contain-all 1 2 9; set result $status) >/dev/null expect $result --to-equal 1 end end diff --git a/plugins/fish-spec/spec/expect.to_not_contain.spec.fish b/plugins/fish-spec/spec/expect.to_not_contain.spec.fish deleted file mode 100644 index 2fe1c4b..0000000 --- a/plugins/fish-spec/spec/expect.to_not_contain.spec.fish +++ /dev/null @@ -1,65 +0,0 @@ -import plugins/fish-spec - -function describe_expect_to_not_contain - function before_each - set -e result - end - - function it_returns_1_when_lists_are_the_same - set -l list 1 2 - - echo (expect $list --to-not-contain $list; set result $status) >/dev/null - expect $result --to-equal 1 - end - - function it_returns_0_when_lists_are_different - set -l list 1 2 - - echo (expect $list --to-not-contain 8 9; set result $status) >/dev/null - expect $result --to-equal 0 - end - - function it_returns_1_when_lists_have_the_same_items_but_in_different_order - set -l list 1 2 - - echo (expect $list --to-not-contain 2 1; set result $status) >/dev/null - expect $result --to-equal 1 - end - - function it_returns_1_when_expected_list_contains_an_item - set -l list 1 2 - - echo (expect $list --to-not-contain 1; set result $status) >/dev/null - expect $result --to-equal 1 - end - - function it_returns_0_when_expected_list_does_not_contain_an_item - set -l list 1 2 - - echo (expect $list --to-not-contain 9; set result $status) >/dev/null - expect $result --to-equal 0 - end - - function it_returns_1_when_expected_list_contains_all_items - set -l list 1 2 3 - - echo (expect $list --to-not-contain 1 2; set result $status) >/dev/null - expect $result --to-equal 1 - end - - function it_returns_0_when_expected_array_does_not_contain_any_items - set -l list 1 2 3 - - echo (expect $list --to-not-contain 1 2 9; set result $status) >/dev/null - expect $result --to-equal 0 - end - - function it_returns_0_when_expected_array_contains_less_items - set -l list 1 2 - - echo (expect $list --to-not-contain 1 2 9; set result $status) - expect $result --to-equal 0 - end -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish b/plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish new file mode 100644 index 0000000..0f8a7f2 --- /dev/null +++ b/plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish @@ -0,0 +1,49 @@ +import plugins/fish-spec + +function describe_expect_to_not_contain_all + function before_each + set -e result + end + + function it_is_false_when_lists_are_the_same + echo (expect 1 2 --to-not-contain-all 1 2; set result $status) >/dev/null + expect $result --to-equal 1 + end + + function it_is_true_when_lists_are_different + echo (expect 1 2 --to-not-contain-all 8 9; set result $status) >/dev/null + expect $result --to-equal 0 + end + + function it_is_false_when_lists_have_the_same_items_but_in_different_order + echo (expect 1 2 --to-not-contain-all 2 1; set result $status) >/dev/null + expect $result --to-equal 1 + end + + function it_is_false_when_expected_list_contains_an_item + echo (expect 1 2 --to-not-contain-all 1; set result $status) >/dev/null + expect $result --to-equal 1 + end + + function it_is_true_when_expected_list_does_not_contain_an_item + echo (expect 1 2 --to-not-contain-all 9; set result $status) >/dev/null + expect $result --to-equal 0 + end + + function it_is_false_when_expected_list_contains_all_items + echo (expect 1 2 3 --to-not-contain-all 1 2; set result $status) >/dev/null + expect $result --to-equal 1 + end + + function it_is_true_when_expected_array_does_not_contain_any_items + echo (expect 1 2 3 --to-not-contain-all 8 9; set result $status) >/dev/null + expect $result --to-equal 0 + end + + function it_is_true_when_expected_array_contains_less_items + echo (expect 1 2 --to-not-contain-all 1 2 9; set result $status) + expect $result --to-equal 0 + end +end + +spec.run $argv diff --git a/plugins/fish-spec/spec/list.erase.spec.fish b/plugins/fish-spec/spec/list.erase.spec.fish index 5924dbe..777ff8e 100644 --- a/plugins/fish-spec/spec/list.erase.spec.fish +++ b/plugins/fish-spec/spec/list.erase.spec.fish @@ -8,42 +8,42 @@ function describe_list.erase function it_erases_one_element list.erase 1 nums_until_10 - expect $nums_until_10 --to-not-contain 1 + expect $nums_until_10 --to-not-contain-all 1 end function it_erases_one_element_without_from_option list.erase 1 --from nums_until_10 - expect $nums_until_10 --to-not-contain 1 + expect $nums_until_10 --to-not-contain-all 1 end function it_erases_one_element_from_multiple_lists list.erase 1 --from nums_until_10 odds_until_10 - expect $nums_until_10 --to-not-contain 1 - and expect $odds_until_10 --to-not-contain 1 + expect $nums_until_10 --to-not-contain-all 1 + and expect $odds_until_10 --to-not-contain-all 1 end function it_erases_one_element_from_multiple_lists_when_only_one_has_the_element list.erase 2 --from nums_until_10 odds_until_10 - expect $nums_until_10 --to-not-contain 2 + expect $nums_until_10 --to-not-contain-all 2 end function it_erases_multiple_elements list.erase 1 2 nums_until_10 - expect $nums_until_10 --to-not-contain 1 - and expect $nums_until_10 --to-not-contain 2 + expect $nums_until_10 --to-not-contain-all 1 + and expect $nums_until_10 --to-not-contain-all 2 end function it_erases_multiple_elements_with_from_syntax list.erase 1 2 --from nums_until_10 - expect $nums_until_10 --to-not-contain 1 - and expect $nums_until_10 --to-not-contain 2 + expect $nums_until_10 --to-not-contain-all 1 + and expect $nums_until_10 --to-not-contain-all 2 end function it_erases_multiple_elements_from_multiple_lists list.erase 1 2 --from nums_until_10 odds_until_10 - expect $nums_until_10 --to-not-contain 1 - and expect $nums_until_10 --to-not-contain 2 - and expect $odds_until_10 --to-not-contain 1 + expect $nums_until_10 --to-not-contain-all 1 + and expect $nums_until_10 --to-not-contain-all 2 + and expect $odds_until_10 --to-not-contain-all 1 end function it_returns_0_if_any_items_are_erased diff --git a/spec/oh-my-fish.spec.fish b/spec/oh-my-fish.spec.fish index a5d5658..b0c3764 100755 --- a/spec/oh-my-fish.spec.fish +++ b/spec/oh-my-fish.spec.fish @@ -37,7 +37,7 @@ function describe_oh_my_fish list.erase "$fish_path/functions/" --from fish_function_path load_oh_my_fish - expect $fish_function_path --to-contain $fish_path/functions/ + expect $fish_function_path --to-contain-all $fish_path/functions/ end function it_loads_all_selected_plugins @@ -46,8 +46,8 @@ function describe_oh_my_fish set -g fish_plugins bak z load_oh_my_fish - expect $fish_function_path --to-contain $fish_path/plugins/bak - expect $fish_function_path --to-contain $fish_path/plugins/z + expect $fish_function_path --to-contain-all $fish_path/plugins/bak + expect $fish_function_path --to-contain-all $fish_path/plugins/z end function it_loads_the_selected_theme @@ -55,7 +55,7 @@ function describe_oh_my_fish set fish_theme l load_oh_my_fish - expect $fish_function_path --to-contain $fish_path/themes/l + expect $fish_function_path --to-contain-all $fish_path/themes/l end function it_reloads_with_status_of_0