Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
nethad committed Oct 3, 2023
1 parent 4b5602a commit b3745e7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions relationship_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# Below are a couple of tests. They don't run because the described
# class (Relationship) is not implemented. It's your task to make them pass!
#
# Notes:
# Notes:
# - Some tests also require you to change the original Bug class.
# - Remove the `skip` method calls to work on the test. By default, we skip all the tests so you can focus
# on them one by one. Remove the skip method call and work on the test until it is green,
# on them one by one. Remove the skip method call and work on the test until it is green,
# then move on to the next test.
#

Expand All @@ -40,6 +40,7 @@ def setup
# 'mother') and the two bugs that are part of the relationship.
def test_1_relationship_attributes
skip # remove this line when you want to work on this test

assert_equal("father", @father_relationship.kind)
assert_equal(@father_bug, @father_relationship.bug1)
assert_equal(@child_bug, @father_relationship.bug2)
Expand All @@ -48,13 +49,28 @@ def test_1_relationship_attributes
# This tests a method that returns a textual description of a relationship.
def test_2_relationship_description
skip # remove this line when you want to work on this test

assert_equal("Harry is Larry's father", @father_relationship.description)
end

# This tests a method that returns a textual description of a relationship
# again and makes sure that you don't cheat ;-)
def test_2b_relationship_description
skip # remove this line when you want to work on this test

mother_relationship = Relationship.new("mother")
mother_bug = Bug.new("Carrie")
mother_relationship.bug1 = mother_bug
mother_relationship.bug2 = @child_bug

assert_equal("Carrie is Larry's mother", mother_relationship.description)
end

# So far, the bugs "know" nothing about their relationships. Let's change that
# by making this test pass!
def test_3_bug_has_relationships
skip # remove this line when you want to work on this test

assert_includes(@father_bug.relationships, @father_relationship)
assert_includes(@child_bug.relationships, @father_relationship)
end
Expand All @@ -63,8 +79,8 @@ def test_3_bug_has_relationships
# a textual summary of their relationships.
def test_4_bug_relationship_summary
skip # remove this line when you want to work on this test
mother_relationship = Relationship.new("mother")

mother_relationship = Relationship.new("mother")
mother_bug = Bug.new("Carrie")

mother_relationship.bug1 = mother_bug
Expand Down

0 comments on commit b3745e7

Please sign in to comment.