Skip to content

Instantly share code, notes, and snippets.

@therod
Created January 19, 2017 09:43
Show Gist options
  • Save therod/8e21597c643039b61360320b90a044dd to your computer and use it in GitHub Desktop.
Save therod/8e21597c643039b61360320b90a044dd to your computer and use it in GitHub Desktop.
# We require the minitest library
require 'minitest/autorun'
# CLASS DEFINITION
class Person
attr_accessor :age, :name
def say(name)
"Hi, my name is test blablabla #{name}"
end
end
# TESTS FOR THE PERSON CLASS
class PersonTest < Minitest::Test
def setup
@angela = Person.new
end
def test_say
assert_match /Angela/, @angela.say("Angela")
assert_kind_of String, @angela.say("Angela")
end
def test_age
@angela.age = 20
assert_equal 20, @angela.age
end
def test_respond_to_name
assert_respond_to @angela, :name
assert_respond_to @angela, :age
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment