Closes #322: rename to-(not-)contain to to-(not-)contain-all

pull/2/head
Bruno Pinto 10 years ago
parent 9a7292ac9d
commit 5e2f42c3b4

@ -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

@ -7,13 +7,13 @@
# OPTIONS
# <expected>...
# <condition>
# --to-equal <actual> value equals <expected> value
# --to-not-equal <actual> value does not equals <expected> value
# --to-equal <actual> value equals <expected> value
# --to-not-equal <actual> value does not equals <expected> value
#
# --to-contain <actual> values exist in <expected> list
# --to-not-contain <actual> values does not exist in <expected> list
# --to-be-true exit status should be truthy
# --to-be-false exit status should be falsy
# --to-contain-all all <actual> values exist in <expected> list
# --to-not-contain-all all <actual> values does not exist in <expected> list
# --to-be-true exit status should be truthy
# --to-be-false exit status should be falsy
# <actual>...
#
# 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

@ -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

@ -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

@ -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

@ -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

@ -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

Loading…
Cancel
Save