Created
February 28, 2014 03:08
-
-
Save elct9620/9264408 to your computer and use it in GitHub Desktop.
A simple ruby block usage.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# Ruby Block | |
### | |
@buffer = "" | |
def test(description, &block) | |
if block_given? | |
puts "##{description}" | |
yield | |
else | |
puts "Pending ##{description}" | |
end | |
end | |
def assert(value, expect) | |
if value == expect | |
@buffer << "." | |
else | |
@buffer << "x" | |
puts "Failed! Get #{value} but expect #{expect}" | |
end | |
end | |
test "No block given" | |
test "Succes" do | |
assert(true, true) | |
end | |
test "Faile" do | |
assert(true, false) | |
end | |
puts @buffer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment