Skip to content

Instantly share code, notes, and snippets.

@MattPorto
Created August 3, 2016 23:57
Show Gist options
  • Save MattPorto/c44951bcb640a6ff0bd03f0fe664c029 to your computer and use it in GitHub Desktop.
Save MattPorto/c44951bcb640a6ff0bd03f0fe664c029 to your computer and use it in GitHub Desktop.
Unit Test Study
class SimpleCount
def initialize(num)
raise unless num.is_a?(Numeric)
@i = num
end
def count
if @i % 35==0
@i = "Nama Team"
puts @i
elsif @i % 7==0
@i = "Team"
puts @i
elsif @i % 5==0
@i = "Nama"
puts @i
else
puts @i
end
return @i
end
end
#Comente as linhas 30, 31 e 32 antes de rodar os testes!
for i in 1..100
SimpleCount.new(i).count
end
require_relative "count"
require "test/unit"
class TestSimpleCount < Test::Unit::TestCase
def test_nama
i = 5
assert_equal("Nama", SimpleCount.new(i).count)
end
def test_team
i = 14
assert_equal("Team", SimpleCount.new(i).count)
end
def test_nama_team
i = 70
assert_equal("Nama Team", SimpleCount.new(i).count)
end
def test_num
i = 18
assert_equal(18, SimpleCount.new(i).count)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment