Skip to content

Instantly share code, notes, and snippets.

@elct9620
Created February 28, 2014 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elct9620/9264408 to your computer and use it in GitHub Desktop.
Save elct9620/9264408 to your computer and use it in GitHub Desktop.
A simple ruby block usage.
###
# 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