mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
moving to a new repo
This commit is contained in:
40
about_basics.rb
Normal file
40
about_basics.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env ruby
|
||||
# -*- ruby -*-
|
||||
|
||||
require 'edgecase'
|
||||
|
||||
class AboutAsserts < EdgeCase::Koan
|
||||
|
||||
# We shall contemplate truth by testing reality, via asserts.
|
||||
def test_assert_truth
|
||||
assert false # This should be true
|
||||
end
|
||||
|
||||
# Enlightenment may be more easily achieved with appropriate
|
||||
# messages.
|
||||
def test_assert_with_message
|
||||
assert false, "This should be true -- Please fix this"
|
||||
end
|
||||
|
||||
# To understand reality, we must compare our expectations against
|
||||
# reality.
|
||||
def test_assert_equality
|
||||
expected_value = 3
|
||||
actual_value = 1 + 1
|
||||
|
||||
assert expected_value == actual_value
|
||||
end
|
||||
|
||||
# Some ways of asserting equality are better than others.
|
||||
def test_a_better_way_of_asserting_equality
|
||||
expected_value = 3
|
||||
actual_value = 1 + 1
|
||||
|
||||
assert_equal expected_value, actual_value
|
||||
end
|
||||
|
||||
# Sometimes we will ask you to fill in the values
|
||||
def test_fill_in_values
|
||||
assert_equal __, 1 + 1
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user