Fixed missed test case.
[ruby_koans.git] / src / about_asserts.rb
1 #!/usr/bin/env ruby
2 # -*- ruby -*-
3
4 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
5
6 class AboutAsserts < EdgeCase::Koan
7
8   # We shall contemplate truth by testing reality, via asserts.
9   def test_assert_truth
10     #--
11     assert true                 # This should be true
12     if false
13     #++
14     assert false                # This should be true
15     #--
16     end
17     #++
18   end
19
20   # Enlightenment may be more easily achieved with appropriate
21   # messages.
22   def test_assert_with_message
23     #--
24     assert true, "This should be true -- Please fix this"
25     if false
26     #++
27     assert false, "This should be true -- Please fix this"
28     #--
29     end
30     #++
31   end
32
33   # To understand reality, we must compare our expectations against
34   # reality.
35   def test_assert_equality
36     expected_value = __(2)
37     actual_value = 1 + 1
38
39     assert expected_value == actual_value
40   end
41
42   # Some ways of asserting equality are better than others.
43   def test_a_better_way_of_asserting_equality
44     expected_value = __(2)
45     actual_value = 1 + 1
46
47     assert_equal expected_value, actual_value
48   end
49
50   # Sometimes we will ask you to fill in the values
51   def test_fill_in_values
52     assert_equal __(2), 1 + 1
53   end
54 end