Commit 99ea3a69 authored by Bruno Pinto's avatar Bruno Pinto

simplifying expect tests

parent b8252160
import plugins/fish-spec
function describe_expect_to_be_false
function before_each
set -e result
end
function it_returns_1_when_evaluated_value_is_0
echo (expect true --to-be-false; set result $status) >/dev/null
expect $result --to-equal 1
expect true --to-be-false
expect $status --to-equal 1
end
function it_returns_0_when_evaluated_value_is_1
echo (expect false --to-be-false; set result $status) >/dev/null
expect $result --to-equal 0
expect false --to-be-false
expect $status --to-equal 0
end
function it_returns_1_when_evaluated_function_returns_0
echo (expect "eval true" --to-be-false; set result $status) >/dev/null
expect $result --to-equal 1
expect "eval true" --to-be-false
expect $status --to-equal 1
end
function it_returns_0_when_evaluated_function_returns_1
echo (expect "eval false" --to-be-false; set result $status) >/dev/null
expect $result --to-equal 0
expect "eval false" --to-be-false
expect $status --to-equal 0
end
end
......
import plugins/fish-spec
function describe_expect_to_be_true
function before_each
set -e result
end
function it_returns_0_when_evaluated_value_returns_0
echo (expect true --to-be-true; set result $status) >/dev/null
expect $result --to-equal 0
expect true --to-be-true
expect $status --to-equal 0
end
function it_returns_1_when_evaluated_value_returns_1
echo (expect false --to-be-true; set result $status) >/dev/null
expect $result --to-equal 1
expect false --to-be-true
expect $status --to-equal 1
end
function it_returns_0_when_evaluated_function_returns_0
echo (expect "eval true" --to-be-true; set result $status) >/dev/null
expect $result --to-equal 0
expect "eval true" --to-be-true
expect $status --to-equal 0
end
function it_returns_1_when_evaluated_function_returns_1
echo (expect "eval false" --to-be-true; set result $status) >/dev/null
expect $result --to-equal 1
expect "eval false" --to-be-true
expect $status --to-equal 1
end
end
......
import plugins/fish-spec
function describe_expect_to_contain_all
function before_each
set -e result
end
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 $result --to-equal 0
expect $status --to-equal 0
end
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 $result --to-equal 1
expect $status --to-equal 1
end
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 $result --to-equal 0
expect $status --to-equal 0
end
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 $result --to-equal 0
expect $status --to-equal 0
end
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 $result --to-equal 1
expect $status --to-equal 1
end
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 $result --to-equal 0
expect $status --to-equal 0
end
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 $result --to-equal 1
expect $status --to-equal 1
end
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 $result --to-equal 1
expect $status --to-equal 1
end
end
......
import plugins/fish-spec
function describe_expect_to_equal
function before_each
set -e result
end
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 $result --to-equal 0
expect $status --to-equal 0
end
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 $result --to-equal 1
expect $status --to-equal 1
end
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 $result --to-equal 0
expect $status --to-equal 0
end
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 $result --to-equal 1
expect $status --to-equal 1
end
end
......
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
expect 1 2 --to-not-contain-all 1 2
expect $status --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
expect 1 2 --to-not-contain-all 8 9
expect $status --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
expect 1 2 --to-not-contain-all 2 1
expect $status --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
expect 1 2 --to-not-contain-all 1
expect $status --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
expect 1 2 --to-not-contain-all 9
expect $status --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
expect 1 2 3 --to-not-contain-all 1 2
expect $status --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
expect 1 2 3 --to-not-contain-all 8 9
expect $status --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
expect 1 2 --to-not-contain-all 1 2 9
expect $status --to-equal 0
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment