10 March 2008
andRuby has dedicated keywords like if and else to define conditional logic. Other languages, like IO, use methods for conditional execution of code. Manfred shows how you can use a class in Ruby to do something similar.
10 March 2008
andRuby has dedicated keywords like if and else to define conditional logic. Other languages, like IO, use methods for conditional execution of code. Manfred shows how you can use a class in Ruby to do something similar.
@run = run
end
yield if @run
end
end
yield
Else.new(false)
rescue LoadError
Else.new(true)
end
require_mocha do
yield
end.else do
puts "Please install mocha to run all the tests."
end
end
end
end
needs_mocha do
truth = true
truth.expects(:is_true?).returns(true)
assert truth.is_true?
end
end
end