forked from thumblemonks/riot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
negative_assertion_test.rb
36 lines (26 loc) · 1.28 KB
/
negative_assertion_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'teststrap'
context "A negative assertion test" do
helper(:negative_assertion) do |definition|
Riot::Assertion.new("foo", true) { definition }
end
asserts("response when evaluated with false result") do
negative_assertion(false).run(Riot::Situation.new)
end.equals([:pass, ""])
asserts("response when evaluated with nil result") do
negative_assertion(false).run(Riot::Situation.new)
end.equals([:pass, ""])
asserts("response when evaluated with true result") do
negative_assertion(true).run(Riot::Situation.new)
end.equals([:fail, "Expected non-true but got true instead", nil, nil])
asserts("response when evaluated with \"bar\" result") do
negative_assertion("bar").run(Riot::Situation.new)
end.equals([:fail, "Expected non-true but got \"bar\" instead", nil, nil])
asserts("response when evaluated with 0 result") do
negative_assertion(0).run(Riot::Situation.new)
end.equals([:fail, "Expected non-true but got 0 instead", nil, nil])
helper(:big_exception) { @exception ||= Exception.new("blah") }
asserts("response when evaluation errors") do
exception = big_exception # :\
Riot::Assertion.new("foo", true) { raise exception }.run(Riot::Situation.new)
end.equals { [:error, big_exception] }
end # A negative assertion test