Ruby cheasheet

less than 1 minute read

# 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/

Categories: , ,

Updated:

Leave a Comment