simplifying expect tests

This commit is contained in:
Bruno Pinto 2015-01-20 22:10:39 -02:00
parent b825216053
commit 99ea3a6989
5 changed files with 72 additions and 88 deletions

View File

@ -1,28 +1,28 @@
import plugins/fish-spec import plugins/fish-spec
function describe_expect_to_be_false function describe_expect_to_be_false
function before_each
set -e result
end
function it_returns_1_when_evaluated_value_is_0 function it_returns_1_when_evaluated_value_is_0
echo (expect true --to-be-false; set result $status) >/dev/null expect true --to-be-false
expect $result --to-equal 1
expect $status --to-equal 1
end end
function it_returns_0_when_evaluated_value_is_1 function it_returns_0_when_evaluated_value_is_1
echo (expect false --to-be-false; set result $status) >/dev/null expect false --to-be-false
expect $result --to-equal 0
expect $status --to-equal 0
end end
function it_returns_1_when_evaluated_function_returns_0 function it_returns_1_when_evaluated_function_returns_0
echo (expect "eval true" --to-be-false; set result $status) >/dev/null expect "eval true" --to-be-false
expect $result --to-equal 1
expect $status --to-equal 1
end end
function it_returns_0_when_evaluated_function_returns_1 function it_returns_0_when_evaluated_function_returns_1
echo (expect "eval false" --to-be-false; set result $status) >/dev/null expect "eval false" --to-be-false
expect $result --to-equal 0
expect $status --to-equal 0
end end
end end

View File

@ -1,28 +1,28 @@
import plugins/fish-spec import plugins/fish-spec
function describe_expect_to_be_true function describe_expect_to_be_true
function before_each
set -e result
end
function it_returns_0_when_evaluated_value_returns_0 function it_returns_0_when_evaluated_value_returns_0
echo (expect true --to-be-true; set result $status) >/dev/null expect true --to-be-true
expect $result --to-equal 0
expect $status --to-equal 0
end end
function it_returns_1_when_evaluated_value_returns_1 function it_returns_1_when_evaluated_value_returns_1
echo (expect false --to-be-true; set result $status) >/dev/null expect false --to-be-true
expect $result --to-equal 1
expect $status --to-equal 1
end end
function it_returns_0_when_evaluated_function_returns_0 function it_returns_0_when_evaluated_function_returns_0
echo (expect "eval true" --to-be-true; set result $status) >/dev/null expect "eval true" --to-be-true
expect $result --to-equal 0
expect $status --to-equal 0
end end
function it_returns_1_when_evaluated_function_returns_1 function it_returns_1_when_evaluated_function_returns_1
echo (expect "eval false" --to-be-true; set result $status) >/dev/null expect "eval false" --to-be-true
expect $result --to-equal 1
expect $status --to-equal 1
end end
end end

View File

@ -1,64 +1,52 @@
import plugins/fish-spec import plugins/fish-spec
function describe_expect_to_contain_all function describe_expect_to_contain_all
function before_each
set -e result
end
function it_returns_0_when_lists_are_the_same function it_returns_0_when_lists_are_the_same
set -l array 1 2 expect 1 2 --to-contain-all 1 2
echo (expect $array --to-contain-all $array; set result $status) >/dev/null expect $status --to-equal 0
expect $result --to-equal 0
end end
function it_returns_1_when_lists_are_different function it_returns_1_when_lists_are_different
set -l array 1 2 expect 1 2 --to-contain-all 8 9
echo (expect $array --to-contain-all 8 9; set result $status) >/dev/null expect $status --to-equal 1
expect $result --to-equal 1
end end
function it_returns_0_when_lists_have_the_same_item_but_in_different_order function it_returns_0_when_lists_have_the_same_item_but_in_different_order
set -l array 1 2 expect 1 2 --to-contain-all 2 1
echo (expect $array --to-contain-all 2 1; set result $status) >/dev/null expect $status --to-equal 0
expect $result --to-equal 0
end end
function it_returns_0_when_expected_list_contains_the_item function it_returns_0_when_expected_list_contains_the_item
set -l array 1 2 expect 1 2 --to-contain-all 1
echo (expect $array --to-contain-all 1; set result $status) >/dev/null expect $status --to-equal 0
expect $result --to-equal 0
end end
function it_returns_1_when_expected_list_does_not_contain_the_item function it_returns_1_when_expected_list_does_not_contain_the_item
set -l array 1 2 expect 1 2 --to-contain-all 9
echo (expect $array --to-contain-all 9; set result $status) >/dev/null expect $status --to-equal 1
expect $result --to-equal 1
end end
function it_returns_0_when_expected_list_contains_all_items function it_returns_0_when_expected_list_contains_all_items
set -l array 1 2 3 expect 1 2 3 --to-contain-all 1 2
echo (expect $array --to-contain-all 1 2; set result $status) >/dev/null expect $status --to-equal 0
expect $result --to-equal 0
end end
function it_returns_1_when_expected_list_does_not_contain_all_items function it_returns_1_when_expected_list_does_not_contain_all_items
set -l array 1 2 3 expect 1 2 3 --to-contain-all 1 2 9
echo (expect $array --to-contain-all 1 2 9; set result $status) >/dev/null expect $status --to-equal 1
expect $result --to-equal 1
end end
function it_returns_1_when_expected_list_contains_less_items function it_returns_1_when_expected_list_contains_less_items
set -l array 1 2 expect 1 2 --to-contain-all 1 2 9
echo (expect $array --to-contain-all 1 2 9; set result $status) >/dev/null expect $status --to-equal 1
expect $result --to-equal 1
end end
end end

View File

@ -1,36 +1,28 @@
import plugins/fish-spec import plugins/fish-spec
function describe_expect_to_equal function describe_expect_to_equal
function before_each
set -e result
end
function it_returns_0_when_compared_values_are_the_same function it_returns_0_when_compared_values_are_the_same
set -l equal "equal" expect 'equal' --to-equal 'equal'
echo (expect $equal --to-equal $equal; set result $status) >/dev/null expect $status --to-equal 0
expect $result --to-equal 0
end end
function it_returns_1_when_compared_values_are_different function it_returns_1_when_compared_values_are_different
set -l equal "equal" expect 'equal' --to-equal 'different'
echo (expect $equal --to-equal 'different'; set result $status) >/dev/null expect $status --to-equal 1
expect $result --to-equal 1
end end
function it_returns_0_when_list_items_are_in_the_same_order function it_returns_0_when_list_items_are_in_the_same_order
set -l array 1 2 expect 1 2 --to-equal 1 2
echo (expect $array --to-equal 1 2; set result $status) >/dev/null expect $status --to-equal 0
expect $result --to-equal 0
end end
function it_returns_1_when_list_items_are_in_different_order function it_returns_1_when_list_items_are_in_different_order
set -l array 1 2 expect 1 2 --to-equal 2 1
echo (expect $array --to-equal 2 1; set result $status) >/dev/null expect $status --to-equal 1
expect $result --to-equal 1
end end
end end

View File

@ -1,48 +1,52 @@
import plugins/fish-spec import plugins/fish-spec
function describe_expect_to_not_contain_all function describe_expect_to_not_contain_all
function before_each
set -e result
end
function it_is_false_when_lists_are_the_same 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 1 2 --to-not-contain-all 1 2
expect $result --to-equal 1
expect $status --to-equal 1
end end
function it_is_true_when_lists_are_different function it_is_true_when_lists_are_different
echo (expect 1 2 --to-not-contain-all 8 9; set result $status) >/dev/null expect 1 2 --to-not-contain-all 8 9
expect $result --to-equal 0
expect $status --to-equal 0
end end
function it_is_false_when_lists_have_the_same_items_but_in_different_order 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 1 2 --to-not-contain-all 2 1
expect $result --to-equal 1
expect $status --to-equal 1
end end
function it_is_false_when_expected_list_contains_an_item 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 1 2 --to-not-contain-all 1
expect $result --to-equal 1
expect $status --to-equal 1
end end
function it_is_true_when_expected_list_does_not_contain_an_item 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 1 2 --to-not-contain-all 9
expect $result --to-equal 0
expect $status --to-equal 0
end end
function it_is_false_when_expected_list_contains_all_items 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 1 2 3 --to-not-contain-all 1 2
expect $result --to-equal 1
expect $status --to-equal 1
end end
function it_is_true_when_expected_array_does_not_contain_any_items 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 1 2 3 --to-not-contain-all 8 9
expect $result --to-equal 0
expect $status --to-equal 0
end end
function it_is_true_when_expected_array_contains_less_items 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 1 2 --to-not-contain-all 1 2 9
expect $result --to-equal 0
expect $status --to-equal 0
end end
end end