Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.60 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class MathClass
  2.  
  3.   attr_accessor :x, :y
  4.  
  5.   def initialize(x, y)
  6.     @x = x
  7.     @y = y
  8.   end
  9.  
  10.   def sum
  11.     @x + @y + 10
  12.   end
  13.  
  14.   def product
  15.     @x * @y
  16.   end
  17.  
  18. end
  19.  
  20.  
  21. require 'rubygems'
  22. require 'test/unit'
  23. require '../math_class.rb'
  24.  
  25. class ThingTest < Test::Unit::TestCase
  26.   def setup
  27.     @math = MathClass.new(2,3)
  28.   end
  29.  
  30.   def test_sets_x_and_y
  31.     assert 2 == @math.x
  32.     assert 3 == @math.y
  33.   end
  34.  
  35.   def test_sum
  36.     assert 5 == @math.sum
  37.   endhttp://assets3.pastie.org/images/paste_button.png?1277948694
  38.  
  39.   def test_sum
  40.     assert 6 == @math.product
  41.   end
  42. end