Ruby cheasheet

# mock power2 function.

def power2(x)
  x * x
end
require "test/unit"
require 'mocha/test_unit'

class TestSimpleNumber < Test::Unit::TestCase
  def test_simple
    expects(:power2).returns(3)
    assert_equal(4, power2(2) )
  end
end

https://learnxinyminutes.com/docs/ruby/

comments powered by Disqus